0

I have gridview with textbox and one Update button outside gridview. When i click on button whatever data changed in textbox those values will update in database.

Here is My Gridview templatefield which is having Textbox

         <asp:TemplateField HeaderText="SeqNo" HeaderStyle-CssClass="gridViolation-status"
                        ItemStyle-CssClass="gridViolation-status" ItemStyle-HorizontalAlign="Center"
                        HeaderStyle-ForeColor="White" SortExpression="STATUS">
                        <ItemTemplate>
                            <asp:TextBox ID="txtSeqNo" runat="server" Width="40%" Text='<%# Bind("VIOLATIONCODESEQNO") %>'
                                onchange="SetValue()"></asp:TextBox>

                        </ItemTemplate>
                    </asp:TemplateField>

and button outside gridview

     <asp:Button ID="btnAdd" runat="server" Text="Update"
                    CssClass="submitbtn"  OnClick="btnAdd_Click" />

I just need to update the value that is in textbox to database without using Foreach

coolprarun
  • 1,153
  • 2
  • 15
  • 22
baby
  • 91
  • 2
  • 5
  • 14
  • You forgot to explain the problem you are facing... – Tadit Dash Sep 12 '13 at 07:24
  • i need update db with data entered in textbox of gridview without using foreach gridview row – baby Sep 12 '13 at 07:25
  • GridView is a collection of many rows. So, if you don't loop, then how can you get the values of each row? – Tadit Dash Sep 12 '13 at 07:27
  • i am using hiddenfield to store textbox value but its not working – baby Sep 12 '13 at 07:29
  • UNless postback it wont save.. – Sasidharan Sep 12 '13 at 07:29
  • i need to set textbox value to hidden field in gridview using textbox onchange event. Can you suggest how to write – baby Sep 12 '13 at 07:30
  • can you share code behind and some more code – Samiey Mehdi Sep 12 '13 at 08:11
  • Try to Refer these links first it has some use full information regarding your post. [http://stackoverflow.com/questions/10683570/updating-datagridview-values-into-database](http://stackoverflow.com/questions/10683570/updating-datagridview-values-into-database) [http://www.codeproject.com/Articles/12846/Auto-Saving-DataGridView-Rows-to-a-SQL-Server-Data](http://www.codeproject.com/Articles/12846/Auto-Saving-DataGridView-Rows-to-a-SQL-Server-Data) [http://stackoverflow.com/questions/520051/c-sharp-issue-how-do-i-save-changes-made-in-a-datagridview-back-to-the-datatabl](http://stackoverflow.com/ – coolprarun Sep 12 '13 at 07:30

0 Answers0