Click here to Skip to main content
15,990,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a grid view with two columns. One named Reg_No and the other named Marks (Marks columns in template field with TextBox in ItemTemplate).

The Reg_No column is bound to the "College" table and it displays the reg_nos from database thro sql datasource.

I need to insert the values into the same database table "College" through textbox in grid view, but I am not sure how to do this. Here is my code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"
       ConnectionString="<%$ ConnectionStrings:WCCConnectionString %>"

       SelectCommand="SELECT [Reg_No] FROM [College] " >


   </asp:SqlDataSource>
   <br />
   <br />
   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
       CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"
       GridLines="None" Height="283px" Width="343px" >
       <AlternatingRowStyle BackColor="White" />
       <Columns>
           <asp:BoundField DataField="Reg_No" HeaderText="Reg_No"
               SortExpression="Reg_No" />
       </Columns>
       <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
       <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
       <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
       <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
       <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
       <SortedAscendingCellStyle BackColor="#FDF5AC" />
       <SortedAscendingHeaderStyle BackColor="#4D0000" />
       <SortedDescendingCellStyle BackColor="#FCF6C0" />
       <SortedDescendingHeaderStyle BackColor="#820000" />
       <Columns>

   <asp:TemplateField HeaderText="Marks">
       <ItemTemplate>
           <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       </ItemTemplate>
   </asp:TemplateField>
   </Columns>

   </asp:GridView>
Posted

1 solution

See this example[^] :)

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900