|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Checkboxes in a datagrid<asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" checked='<%# Eval("BooleanField1") %>' OnCheckedChanged="CheckBox1_CheckedChanged" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true" checked='<%# Eval("BooleanField2") %>' OnCheckedChanged="CheckBox2_CheckedChanged" /> </ItemTemplate> </asp:TemplateField> I want the database to get updated whenever I check or uncheck the CheckBox1, ie the value of "BooleanField1" in the database should be changed to True or False. And same with CheckBox2. How can I accomplish this? Now I can access the DataKeyNames by the following code
protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { CheckBox checkbox = (CheckBox)sender; GridViewRow row = (GridViewRow)checkbox.NamingContainer; Response.Write(row.Cells[0].Text); } But I have kept the 0th column visible=false. Then I cant get it by the above code. Is there any solution for this |
|||||||||||||||||||||||