Jes Sie

Jes Sie

  • 736
  • 1.2k
  • 284.3k

Get The Value of a Gridview Using a Checkbox and Save in DB

Dec 10 2017 11:30 PM
Once again I need some assistance.
 
I have a gridview where its data comes from a certain table in my database. In the gridview, I added a checkbox. Once the checkbox is checked, the value of the ClauseCode will be saved in another table in my database. The sad part is that I don't know how to do it. Below is my markup:
  1. <asp:GridView ID="gvClauses" runat="server" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical" AutoGenerateColumns="False" DataKeyNames="ClauseCode">  
  2.                     <AlternatingRowStyle BackColor="#CCCCCC" />  
  3.                     <Columns>  
  4.                         <asp:TemplateField HeaderText="ClauseID" InsertVisible="False" SortExpression="ClauseID">  
  5.                             <EditItemTemplate>  
  6.                                 <asp:Label ID="Label1" runat="server" Text='<%# Eval("ClauseID") %>'>asp:Label>  
  7.                             EditItemTemplate>  
  8.                             <ItemTemplate>  
  9.                                 <asp:Label ID="Label1" runat="server" Text='<%# Bind("ClauseID") %>'>asp:Label>  
  10.                             ItemTemplate>  
  11.                         asp:TemplateField>  
  12.                         <asp:TemplateField HeaderText="ClauseCode" SortExpression="ClauseCode">  
  13.                             <EditItemTemplate>  
  14.                                 <asp:Label ID="Label2" runat="server" Text='<%# Eval("ClauseCode") %>'>asp:Label>  
  15.                             EditItemTemplate>  
  16.                             <ItemTemplate>  
  17.                                 <asp:Label ID="lblClauseCode" runat="server" Text='<%# Bind("ClauseCode") %>'>asp:Label>  
  18.                             ItemTemplate>  
  19.                         asp:TemplateField>  
  20.                         <asp:TemplateField HeaderText="ClauseDescription" SortExpression="ClauseDescription">  
  21.                             <EditItemTemplate>  
  22.                                 <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ClauseDescription") %>'>asp:TextBox>  
  23.                             EditItemTemplate>  
  24.                             <ItemTemplate>  
  25.                                 <asp:Label ID="Label3" runat="server" Text='<%# Bind("ClauseDescription") %>'>asp:Label>  
  26.                             ItemTemplate>  
  27.                         asp:TemplateField>  
  28.                         <asp:TemplateField HeaderText="Wordings" SortExpression="Wordings" Visible="False">  
  29.                             <EditItemTemplate>  
  30.                                 <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Wordings") %>'>asp:TextBox>  
  31.                             EditItemTemplate>  
  32.                             <ItemTemplate>  
  33.                                 <asp:Label ID="Label4" runat="server" Text='<%# Bind("Wordings") %>'>asp:Label>  
  34.                             ItemTemplate>  
  35.                         asp:TemplateField>  
  36.                         <asp:TemplateField HeaderText="Select">  
  37.                             <ItemTemplate>  
  38.                                 <asp:CheckBox ID="cbSelect" runat="server" OnCheckedChanged="cbSelect_CheckedChanged" />  
  39.                                   
  40.                             ItemTemplate>  
  41.                         asp:TemplateField>  
  42.                     Columns>  
  43.                     <FooterStyle BackColor="#CCCCCC" />  
  44.                     <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />  
  45.                     <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />  
  46.                     <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />  
  47.                     <SortedAscendingCellStyle BackColor="#F1F1F1" />  
  48.                     <SortedAscendingHeaderStyle BackColor="#808080" />  
  49.                     <SortedDescendingCellStyle BackColor="#CAC9C9" />  
  50.                     <SortedDescendingHeaderStyle BackColor="#383838" />  
  51.                 asp:GridView>  
 I tried to search in google for several hours but I haven't found a requirement the same as mine. Hope someone can assist me. Thanks in advance.
 

Answers (1)