How to get the value?
I have a grid view which have checkbox. Now how to get its value o开发者_运维技巧n serverside.
<ItemTemplate>
<asp:CheckBox
ID="chkEditable" runat="server" AlternateText="Is Editable"
OnCheckedChanged="chkEditable_CheckedChanged"
AutoPostBack="true" Value='<%# Eval("PK_ID")%>' />
</ItemTemplate>
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
精彩评论