now we are going to learn how we update the gridview
see this:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id = (int)GridView1.DataKeys[e.RowIndex].Value;
GridViewRow row = GridView1.Rows[e.RowIndex];
string name = ((TextBox)row.FindControl("TextBox1")).Text;
string city = ((TextBox)row.FindControl("TextBox2")).Text;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("update sqltest set Name='" + name + "',City='" + city + "' where CustId='" + id + "'",con);
command.Connection.Open();
command.ExecuteNonQuery();
command.Connection.Close();
GridView1.EditIndex = -1;
BindData();
}
please give your feedback..........
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment