Hi guys,
First thanks a lot to Kaushal and Sanraj fro all your help. I got It working! :) I now have a DataTable built programmatically whose information is displayed in a GridView. The user can change checkboxes relating to the DataTable's fields of type bool and this is reflected in the DataTable through overriding the CheckedChanged event. My code is below in case anyone is interested. Thanks again for all the help!
Default.aspx
1 <asp:GridView ID="BuildsGV" runat="server" >
2 <Columns>
3 <asp:TemplateField HeaderText="EN">
4 <ItemTemplate>
5 <asp:CheckBox ID="EN" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem,"EN")%>' OnCheckedChanged="cbx_CheckedChanged" />
6 </ItemTemplate>
7 </asp:TemplateField>
8 <asp:TemplateField HeaderText="FR">
9 <ItemTemplate>
10 <asp:CheckBox ID="FR" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem,"FR")%>' OnCheckedChanged="cbx_CheckedChanged"/>
11 </ItemTemplate>
12 </asp:TemplateField>
13 </Columns>
14 </asp:GridView>
15
Code Behind Page
1 protected void cbx_CheckedChanged(object sender, EventArgs e)
2 {
3 //the checkbox that triggered the change event.
4 CheckBox cbx = (CheckBox)sender;
5 CheckBox currBox = new CheckBox();
6 DataRow editRow = confirmationData.Rows[0];
7 int numRows = 0;
8
9 //loop through the rows.
10 foreach(GridViewRow item in BuildsGV.Rows)
11 {
12 currBox = (CheckBox)item.FindControl("EN");
13
14 if (currBox.Equals(cbx))
15 {
16 //update the corresponding language field in the DataTable.
17 editRow = confirmationData.Rows[numRows];
18 editRow["EN"] = cbx.Checked;
19
20 //match found, no need to search any further.
21 break;
22 }
23
24 currBox = (CheckBox)item.FindControl("FR");
25
26 if (currBox.Equals(cbx))
27 {
28 //update the corresponding language field in the DataTable.
29 editRow = confirmationData.Rows[numRows];
30 editRow["FR"] = cbx.Checked;
31
32 //match found, no need to search any further.
33 break;
34 }
35
36 numRows++;
37 }
38 }