Link to home
Start Free TrialLog in
Avatar of tryokane
tryokane

asked on

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

Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Check if this is enough for you http://forums.asp.net/p/1210560/2131957.aspx
Avatar of tryokane
tryokane

ASKER

Can we insert the data in the gridview row command.How to do?
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
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?
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for ur response.