[問題] GridViewUpdatedEventArgs取不到OldValues集合
各位版友好, 小弟我在GridView.Updated事件處理常式中, 想要利用GridViewUpdatedEventArgs.OldValues來取得並比較資料更新前後的不同處. 但是不管是否發生Exception, GridViewUpdatedEventArgs.OldValues都是null 不知道是不是我的用法有問題? GridViewUpdatedEventArgs.NewValues就有值.
我的程式碼如下:
void TemplateProjectItemGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
if (e.Exception != null)
{
this.TemplateProjectItemErrorLabel.Text = "更新專案項次失敗";
e.ExceptionHandled = true;
}
if ((bool)e.OldValues["status"] == false && (bool)e.NewValues["status"] == true)
^^^^^^^^^^^^^^^^^^^null 有值^^^^^^^^^^^^^^^^^^
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "RecurringAddProjectItem", "if(window.confirm('是否根據此專案項次再次新增同樣內容的專案項次?')){" + this.TemplateProjectItemInsertLinkButton.ClientID + ".click()};", true);
}
}
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.56.130.54
※ 編輯: liunate 來自: 61.56.130.54 (05/03 11:44)
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章