protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
GridView1.DataBind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
GridView1.DataBind();
}
行編輯和行取消編輯做工精細;但是當我在更改文本框中的值後按更新時,它顯示的舊值不是我已更改的值。以下是行更新事件代碼。
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
dao.AridNumber = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
dao.FirstName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
dao.LastName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
}
更新我!
我也將檢查需要綁定我不記得是什麼事件,但聽起來像使用GridView1.DataBind()後DataBind()問題 – MethodMan 2011-12-29 18:21:35