How to insert data from the gridview in to the database?

I have represented data into gridview's one column,into another column i put a textbox for accepting user's data in each row.Now i want to input all data from both columns in to the database.Can u tell me how to do.Code is appreciated?
<asp:GridView ID="GridView1" runat="server"  Style="z-index: 102; left: 22px; position: absolute;top: 21px" Width="407px" AutoGenerateColumns="false" Height="176px" OnRowCommand="GridView1_RowCommand" >
           <Columns>
         <asp:TemplateField>
            <ItemTemplate>
               <asp:DropDownList ID="ddlOrder" runat="server">
                        <asp:ListItem>View</asp:ListItem>
                        <asp:ListItem>Delete</asp:ListItem>
                        <asp:ListItem>Both</asp:ListItem>
                         </asp:DropDownList>&nbsp;
                          </ItemTemplate>
           </asp:TemplateField>
            <asp:BoundField DataField="controlvalue" HeaderText="FormFillerIds" >
              <ItemStyle BackColor="White" />
          </asp:BoundField>
                 <asp:TemplateField>
                 <ItemTemplate>
                  
                  <asp:Button ID="Button1" runat="server" Text="Insert" OnClick="Button1_Click" Width="70px" Height="30px" />
            
                 </ItemTemplate>
                 </asp:TemplateField>
         </Columns>
              
        </asp:GridView>

Open in new window

LVL 2
tryokaneAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
Not in the gridview. Is't not like winforms datagridview that you can add, change, delete, update.

You can use a DetailsView to do that. Check in this link in the end (last two example) http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/detailsview.aspx

Again the easy way is to add some textboxes and a button to insert and after the insert just bind the gridview for refresh the itens.
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Check if this is enough for you http://forums.asp.net/p/1210560/2131957.aspx
0
 
tryokaneAuthor Commented:
Can we insert the data in the gridview row command.How to do?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Jorge PaulinoIT Pro/DeveloperCommented:
Yes, using the edit, update and delete but add i don't know ... Normally the gridview is bind to some datasource and you add data to the data source and then refresh the gridview.

Can you explain better what you want ?

Check this video helps http://www.asp.net/learn/videos/video-07.aspx
Or this link (it has very good starting manuals) http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/gridview.aspx
0
 
tryokaneAuthor Commented:
what i want is i want to insert the data from each row in to database.I am placing an insert button in each row.I want to insert each row in to the database on clicking the button.Can we use gridview row command for this insertion.If so can u tell me how?
0
 
tryokaneAuthor Commented:
Thanks for ur response.
0
All Courses

From novice to tech pro — start learning today.