tags:

views:

65

answers:

1

I have a grid view which have checkbox. Now how to get its value on serverside.

<ItemTemplate>
  <asp:CheckBox 
    ID="chkEditable" runat="server" AlternateText="Is Editable"
    OnCheckedChanged="chkEditable_CheckedChanged" 
    AutoPostBack="true" Value='<%# Eval("PK_ID")%>' />
</ItemTemplate>
+1  A: 
 protected void chkEditable_OnCheckedChanged(object sender, EventArgs e)
        {
            GridViewRow gv = (GridViewRow)(((Control)sender).NamingContainer);
            int pk  = this.GridView1.DataKeys[gv.RowIndex].Value.ToString();
            // Get the reference of this CheckBox

            CheckBox chk = gv.FindControl("chkEditable") as CheckBox ;
            //do stuff

        }

Add the event handler manually to the code behind page

chugh97