2017-08-24 35 views
0

我需要一些幫助,因爲我無法找到問題的解決方案。我已經通過Stackoverflow以及Microsoft站點上的許多解決方案,但無法找到問題。在Visual Studio 2005中沒有觸發GridView_RowUpdating事件

我在VS2005中有一個Gridview,但rowupdating evvent沒有觸發,當我在GridView中的更新按鈕時鐘。

以下是.aspx代碼。任何人都可以幫助我理解我在這裏錯過了什麼。

asp:GridView ID="dbgrdReport" 
CellPadding="4" 
EnableTheming="True" 
AutoGenerateColumns="False" 
SkinID="GridFormat" 
ShowFooter="True" 
AllowSorting="True" 
runat="server" 
OnSorting="dbgrdReport_Sorting" 
OnRowEditing="dbgrdReport_RowEditing" 
OnRowUpdating="dbgrdReport_RowUpdating" 
OnRowCancelingEdit="dbgrdReport_RowCanceling" 
OnRowDeleting="dbgrdReport_RowDeleting"> 

回答

1

您已經添加了正確的屬性OnRowUpdating="dbgrdReport_RowUpdating"到GridView控件。

然後,還有,你必須檢查很多東西:

  • 屬性框-->活動-->OnRowUpdating實現。
  • GridView中的所有控件都沒有相同的ID。
  • Set AutoGenerateEditButton="False"
  • 使用下面的代碼的「編輯」按鈕字段添加到你的GridView的代碼如下:

    <asp:commandfield showeditbutton="true" causesvalidation="false" headertext="Edit"/> 
    
  • 設置GridView控件EnableViewState屬性爲true。
  • 綁定您的GridView if(!IsPostBack)而不是PostBack Page_Load方法。
  • -