Hi ,
Try this
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (((CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1")) is CheckBox)
{
using (
SqlConnection con =
new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("UPDATE dbo.cate SET cate = @cate , chk = @chk where id = @id", con);
cmd.Parameters.AddWithValue("@cate",
((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text);
cmd.Parameters.AddWithValue("@chk",
((CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1")).Checked);
cmd.Parameters.AddWithValue("@id",
((Label)GridView1.Rows[e.RowIndex].FindControl("Label1")).Text);
cmd.CommandType = System.Data.CommandType.Text;
cmd.ExecuteNonQuery();
cmd.Dispose();
GridView1.EditIndex = -1;
bind();
}
}
Best Regards
M.Mitwalli