我有以下代码:
protected void BtnSave_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = (DataTable)ViewState["CurrentData"];
int id = Convert.ToInt32(Session["id"]);
dt.Rows[index: id + 1][0] = TextBox1.Text;
dt.Rows[index: id + 1][1] = TextBox2.Text;
dt.Rows[index: id + 1][2] = TextBox3.Text;
dt.Rows[index: id + 1][3] = TextBox4.Text;
dt.AcceptChanges();
GridView2.DataSource = dt;
GridView2.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
BtnCancle.Visible = false;
BtnSave.Visible = false;
}
出于某种原因,当我编辑第四行时,第二行的更新更改效果。
谁能看到我做错了什么?