Friday, March 28, 2008

CheckBox in GridView

Add Gridview Control from the ToolBox
once its placed,click on source tab from VSS,there you can see the rendered html tags for the control.
Between closed Gridview tag,add these tags.In itemtemplate portion,you can add anything like button,image,hyperlink etc..each control will be tie-up with record which binded on Gridview.
Actually,this gridview its quite useful for reporting view.Simply we can call the minimal crystalreport for web application.
if you want to view the individual invoice detail on the Bill listing can add hyper link control to GridView,then you make some piece of codeto retrieve the details for corresponding invoice number.
secondly,If there is situation where user has to select multiple choices from the GridviewReport.we go for checkbox option.
Added checkboxes bind with GridViews.
If you wish to select the each row in gridview and find the selected row's value.then code will be,

foreach (GridViewRow row in GridView1.Rows)
CheckBox chb = (CheckBox)row.FindControl("friend");
//You need to identify the control which fired on GridView
if(chb.Checked = true)
selValue= (row.Cells[1].Text) + ',';
I hope this simple explanation will help you to go further up on this !