hi, now we are going to learn how we delete data from gridview
protected void GridView1_RowDeleting(Object sender, GridViewDeleteEventArgs e)
{
int id = (int)GridView1.DataKeys[e.RowIndex].Value;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("delete from sqltest where CustId='"+id+"'",con);
command.Connection.Open();
command.ExecuteNonQuery();
command.Connection.Close();
GridView1.EditIndex = -1;
BindData();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment