开发者

How to get the value?

开发者 https://www.devze.com 2023-01-09 01:53 出处:网络
I have a grid view which have checkbox. Now how to get its value o开发者_运维技巧n serverside.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消