protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string strSNo = e.Keys["SNo"].ToString();
string strSName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
string strCourse = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
string strAddress = ((TextBox)GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text;
string strRoll = ((TextBox)GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text;
cmd = new SqlCommand("Update Student set SName=@SName,Course=@Course,Address=@Address,SRoll=@SRoll where SNo=@SNo", cn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@SName", strSName);
cmd.Parameters.AddWithValue("@Course", strCourse);
cmd.Parameters.AddWithValue("@Address", strAddress);
cmd.Parameters.AddWithValue("@SRoll", strRoll);
if(cn.State != ConnectionState.Open)
cn.Open ...
Go to the complete details ...