Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a webform and I am able to insert data into gridview using temporary table after adding Some records in grid_view from the webform i want to save all the data in database in a single click, Suppose i have 5 column in my table(Database) and only three column in Gridview and two column in webform, in single click all the rows and 5 column, 2 column with same record in the same column like date or ProductReceivedBy and three column from the grid. Can any body help me to find out the solution of this code. I am using VS2005 and SQLServer 2005. Can any body provide me code....
Posted

Hi, There is many techniques for doing this. for this,

Method 1. You can use XML- Create a DataTable at front end and create xml from that data table and send this xml as a parameter to sp.

Method 2. take 5 parameters in sp, 2 for form values, and 3 for grid values. these 3 are varchar(max). at Front end, using foreach make a comma separated string for each column and send to each parameter then in sp, split 3 parameters into tables using split function.
then you can use loop in SP for inserting record in table. I am using 2nd method and works right if understood properly. :-)
 
Share this answer
 
One way you can do that is by loading the gridview in edit mode.
Then you have a button on the page and set this method on click:
C#
protected void Button1_Click(object sender, EventArgs e)
  {
      for (int i = 0; i < GridView1.Rows.Count; i++)
      {
          GridView1.UpdateRow(i, false);    //save the row at index = i

      }
  }
 
Share this answer
 

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