Nethra R S

Nethra R S

  • NA
  • 310
  • 330.5k

Saving gridview data in sql table

Nov 21 2011 11:15 PM
Hi,

I have a gridview with blank rows and i can add rows to the gridview at button clickevent. How do i save the data entered in this gridview to the sql table? here is the source for the gridview:I am dynamically creating rows in the gridview

<asp:GridView ID="GVContactPerson" runat="server" AutoGenerateColumns="False"
                                CssClass="GridViewStyle" ShowFooter="True" UseAccessibleHeader="False"
                                Width="500px">
                                <Columns>
                                    <asp:BoundField DataField="SlNo" HeaderText="SL No" />
                                    <asp:TemplateField HeaderText="Contact Name">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtContactName" runat="server" CssClass="GridItemStyle"
                                                Width="90px"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="EmailID">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtemail" runat="server" CssClass="GridItemStyle" Width="90px"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Mobile">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtmob1" runat="server" CssClass="GridItemStyle" Width="90px"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Status">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="ChkStatus" runat="server" AutoPostBack="false" Checked="true"
                                                CssClass="GridItemStyle" />
                                        </ItemTemplate>
                                        <FooterStyle HorizontalAlign="Right" />
                                        <FooterTemplate>
                                            <asp:ImageButton ID="imgadd" runat="server" Height="20px" ImageAlign="Right"
                                                ImageUrl="~/ImagesFiles/add_button.png" OnClick="imgadd_click"
                                                ToolTip="add another contact" Width="20px" />
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <HeaderStyle BackColor="White" BorderColor="#666666" BorderStyle="Solid"
                                    BorderWidth="2px" Font-Bold="True" ForeColor="#666666" Height="15px" />
                            </asp:GridView>


Answers (1)