Click here to Skip to main content
15,909,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to insert all the data of a gridview to a table in one shot?
Posted

1st select the 1st row details from gridview den use for loop to insert the into new table with additional information.

for(int i=0;i<gridview1.rows.count;i++)>
{
string num = GridView1.Rows[i].Cells[1].Text;
string staff_dept = GridView1.Rows[i].Cells[2].Text;
string str = "insert into intrmarks(VTUNO,dept)values('" + num + "','" + staff_dept + "')";
SqlCommand strCmd = new SqlCommand(str, con);
strCmd.ExecuteNonQuery();
 
}
 
Share this answer
 
v3

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