PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Checkboxes in a datagrid
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Checkboxes in a datagrid
![]() |
Checkboxes in a datagrid |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I have a GridView with a a checkbox as below.
<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? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

