protected void SAVE_GRID_Click(object sender, EventArgs e)
{
int rowscount = GridView2.Rows.Count;
int columnscount = GridView2.Columns.Count;
for (int i = 0; i < rowscount; i++)
{
for (int j = 1; j < columnscount; j++)
{
//I want to get data of each cell in a row
//I want to read the corresponding header and store
}
}
}Loading
Sanjeeb LenkaPosted Sep 21, 2013, 6:05 AM
or try like this:
protected void btninsert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(connStr);
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
con.Open();
str = "insert into itemtable(item,itemcode) values('" + row.Cells[1].Text + "','" + row.Cells[2].Text + "')";
SqlCommand com=new SqlCommand(str,con);
com.ExecuteNonQuery();
con.Close();
}
}