I have Bulk data ,just want to insert that data from Gridview to Database table how it possible?
I have done this way is it correct?
Regards
Sree
I have done this way is it correct?
Code:
protected void btn_insert_Click(object sender, EventArgs e)
{
foreach (GridViewRow g1 in GridView1.Rows)
{
SqlConnection con = new SqlConnection(connStr);
com = new SqlCommand("insert into student(sid,sname,smarks,saddress) values ('" + g1.Cells[0].Text + "','" + g1.Cells[1].Text + "','" + g1.Cells[2].Text + "','" + g1.Cells[3].Text + "')", con);
con.Open();
com.ExecuteNonQuery();
con.Close();
<!--[if !supportEmptyParas]--> <!--[endif]-->
}
Label1.Text = "Records inserted successfully";
}
}
}
Regards
Sree