Click here to Skip to main content
15,886,693 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have grid view like
ASP.NET
<asp:GridView ID="grdSector" runat="server" AutoGenerateColumns="False"  >
                                <columns>
                                    <asp:TemplateField HeaderText="Sectors">
                                        <itemtemplate>
                                           <%# Eval("SectorName")%>
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Roof/ParaPet Clearance in Case of RTT/RTP">
                                        <itemtemplate>
                                            <asp:TextBox ID="_txtClearance" runat="server">
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Azimuth (Degree)">
                                        <itemtemplate>
                                            <asp:TextBox ID="_txtAzimuth" runat="server">
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Ht From Gnd(m)">
                                        <itemtemplate>
                                            <asp:TextBox ID="_txtHeight" runat="server">
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Mount Type">
                                        <itemtemplate>
                                            <asp:Label ID="_lblMountType" runat="server" Text="GBM">
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Ant type">
                                        <itemtemplate>
                                            <asp:TextBox ID="_txtAntType" runat="server">
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Tilt">
                                        <itemtemplate>
                                            <asp:TextBox ID="_txtTilt" runat="server">
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Coverage Objective :- ( Any Important Landmark nearby">
                                        <itemtemplate>
                                            <asp:DropDownList runat="server" ID="_dropObjective">
                                            
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Avg Clutter Height">
                                        <itemtemplate>
                                            <asp:TextBox ID="_txtAvgClutterHeight" runat="server">
                                        </itemtemplate>
                                    
                                </columns>


when user submit the buttom i want to fetch data from textboxes n insert into table in database. can any one help me here
Posted
Updated 14-Dec-11 5:26am
v2

For the retrieval of the data from textboxes you can use .FindControl() method:

C#
foreach(DataRow row in GridView.Rows)
{
  TextBox txtClearence = (textBox)row.FindControl("_txtClearence");
  TextBox txtHeight = (textBox)row.FindControl("_txtHeight");
  string valClearence = txtClearence.Text;
  string valHeight = txtHeight.Text;
}

For insert to the database you can find an example
here[^]

Good luck,
OI
 
Share this answer
 
This might[^] might help you out.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 14-Dec-11 12:20pm    
Never saw the FAQ article before. A good idea. My 5.
--SA
Abhinav S 14-Dec-11 12:23pm    
Thank you SA.
Monjurul Habib 14-Dec-11 14:38pm    
5!
Abhinav S 15-Dec-11 0:23am    
Thank you.
sriman.ch 14-Dec-11 23:23pm    
Nice article....thanks bro...

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