我在Gridview中使用RowUpdating事件。當我更新一行時,gridview中的所有行都會更新。我的代碼是當我更新一行時,gridview中的所有行都得到更新
Con.Open();
SqlCommand cmd = new SqlCommand("update dbo.PersionalDetails set Name='" + txtName.Text + "',Location='" + txtLocation.Text + "' where id=id", Con);
cmd.ExecuteNonQuery();
Con.Close();
Label lblresult = new Label();
lblresult.ForeColor = Color.Green;
lblresult.Text = txtName.Text + " Details Updated successfully";
GridView1.EditIndex = -1;
BindGrid();
請幫忙!!
Id始終等於id ..首先刪除sql注入'''; DROP TABLE xxx; - '....並將您的位置'id = id'更改爲參數 – Nico 2014-10-01 07:20:47