Get value from gridview CheckBoxField on rowcommand event

Use the code on rowcommand event –

GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
int requisitionId = Convert.ToInt32(e.CommandArgument);
CheckBox cbox = (CheckBox)row.Cells[your CheckBoxField column].Controls[0];

 

Access to CheckBoxField is now made easy.

Advertisements

Use GridView BoundField as hyperlink

Let’s say, You have UserId & UserName columns in a gridview. You can use UserName column as hyperlink. The code is following-

<asp:BoundField DataField=”UserId”
HeaderText=”User Id” />

<asp:HyperLinkField
DataTextField=”UserName”    //Datatable column name
DataNavigateUrlFields=”UserId”   //Value is taken from this field dynamically
DataNavigateUrlFormatString=”UserDetails.aspx?ID={0}”    //Page name with a place holder for dynamic data UserId
HeaderText=”User Name” />

Hyperlinked BoundField made easy.