protected void GridView1_RowUpdating1(object sender, GridViewUpdateEventArgs e) { int row = GridView1.EditIndex; GridViewRow rows = GridView1.Rows[e.RowIndex]; if ((((TextBox)rows.FindControl("txtuser_name") != null) && (TextBox)rows.FindControl("txtpassword") != null)) { int id = Convert.ToInt32(GridView1.DataKeys[row].Value.ToString()); TextBox txtuser_name = (TextBox)rows.FindControl("txtuser_name"); TextBox txtpassword = (TextBox)rows.FindControl("txtpassword"); string user_name = txtuser_name.Text; string password = txtpassword.Text; con.Open(); SqlCommand cmd = new SqlCommand("update login set user_name='" + user_name + "',password='" + password + "' where user_id=" + id + "", con); Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('Record Updated')</script>"); cmd.ExecuteNonQuery(); GridView1.EditIndex = -1; con.Close(); bind_login(); } }
FindControl
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)