Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir please provide me code how to solve this problem how to insert data in database form grid view (shopping cart)

my order item table are:


SQL
CREATE TABLE [dbo].[tblOrder_Items] (
    [Id] [int] IDENTITY(1, 1) NOT NULL
    ,[orderId] [int] NULL
    ,[product_id] [int] NULL
    ,[quantity] [int] NULL
    ,[discount] [nvarchar](50) NULL
    ,[total_price] [nvarchar](50) NULL
    ,[applydate] [nvarchar](50) NULL
    ,CONSTRAINT [PK_tblOrderdatail] PRIMARY KEY CLUSTERED ([Id] ASC) WITH (
        PAD_INDEX = OFF
        ,STATISTICS_NORECOMPUTE = OFF
        ,IGNORE_DUP_KEY = OFF
        ,ALLOW_ROW_LOCKS = ON
        ,ALLOW_PAGE_LOCKS = ON
        ) ON [PRIMARY]
    ) ON [PRIMARY] GO
Posted
Updated 15-Sep-14 2:04am
v3

C#
foreach (GridViewRow GR in GridView1.Rows)
       {
           if (GR.RowType == DataControlRowType.DataRow)
           {
               string myField = GR.Cells[1].Text;

               // You can also find grid view inside controls here

               TextBox tb = (TextBox)tt.FindControl("TextBox1");
           }
       }
 
Share this answer
 
Comments
[no name] 17-Sep-14 2:13am    
Thanks Sir
Hi,

Learn How to insert : http://www.w3schools.com/sql/sql_insert.asp[^]
 
Share this answer
 
Comments
[no name] 15-Sep-14 8:08am    
i know how to insert but in shopping cart many product buy by user then how to insert many product in shopping cart
[no name] 15-Sep-14 8:09am    
how to insert data from gridview(shopping cart)
Suvabrata Roy 15-Sep-14 8:12am    
Go through this link : http://www.c-sharpcorner.com/uploadfile/raj1979/select-add-update-and-delete-data-in-a-Asp-Net-gridview-control/
[no name] 15-Sep-14 8:16am    
you are not understand my chat i create shoppping cart website
[no name] 15-Sep-14 8:17am    
i create all page & add cart systems but when buyer click on place order then i want to insert data in database(tblorderitems) from shopping cart(gridview)

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