protected void MyCheckBox_OnCheckedChanged(object sender, EventArgs e)
{
int intDataKey =
Convert.ToInt32(MyGridView.DataKeys[((GridViewRow)((CheckBox)sender).Parent.Parent).RowIndex].Value);
// rest of code
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
You can try the following code to implement the same.
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
Dim chb As CheckBox = e.Row.Cells(2).FindControl("CheckBox1")
AddHandler chb.CheckedChanged, AddressOf check_changed
End If
End Sub
Public Sub check_changed(ByVal sender As Object, ByVal e As EventArgs)
Response.Write(Me.GridView1.DataKeys.Item(CType(CType(sender,
CheckBox).Parent.Parent, GridViewRow).RowIndex).Value)
End Sub
Regards,
Manish
www.componentone.com