my gridview update code is below
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SqlConnection con = new SqlConnection(Class1.con);
int userid1 = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
// Label lblstid = (Label)GridView1.Rows[e.RowIndex].FindControl("lblstId");
TextBox txtiname = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtiname");
TextBox txticode = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtcode");
TextBox txtname = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtname");
TextBox txtaddr= (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtaddr");
TextBox txtgender = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtgender");
TextBox txtoccup = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtoccup");
TextBox txtmob = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtmob");
TextBox txtemail = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtemail");
TextBox txtuser = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtuser");
TextBox txtpass= (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtpass");
TextBox txthint = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txthint");
con.Open();
SqlCommand cmd = new SqlCommand("Update Uregistration set iname='" + txtiname.Text + "',icode='" + txticode.Text + "',name='" + txtname.Text + "',address='" + txtaddr.Text + "',gender='" + txtgender.Text + "',occupation='" + txtoccup.Text.Trim() + "',mob='" + txtmob.Text + "',email='" + txtemail.Text + "',username='" + txtuser.Text + "',password='" + txtpass.Text + "',hint='" + txthint.Text + "' where userid= '" + userid1 + "'", con);
cmd.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Data Updated Successfully');", true);
GridView1.EditIndex = -1;
BindGrid();
}