GridView中的更新按鈕不能觸發RowUpdating事件

來源:互聯網
上載者:User

當點擊“編輯”按鈕以後,可以看到“更新”和“取消”按鈕,“取消”按鈕可以正常觸發RowCancelingEdit事件,但是“更新”按鈕不能觸發RowUpdating事件。

解決方案:

在<asp:CommandField>中添加 CausesValidation="false"

 

Gridview RowUpdating Not Firing (RowUpdating event not firing on update button click for GridView Control)

After i click edit, i will get Update and Cancel button , Cancel Works. But Update doesnt.

It’s a bug of gridview .

Solution:

Add CausesValidation="false" into <asp:CommandField> .

<asp:CommandField ShowEditButton="True" ButtonType="Button" HeaderText="Edit" CausesValidation="false">
    <ItemStyle HorizontalAlign="Center" Width="140px" Font-Size="12px" BorderColor="#3D90CA"
                                   BorderStyle="Solid" BorderWidth="1px" />
    <HeaderStyle CssClass="DivReportHeader" BorderStyle="Solid" Height="20px" ForeColor="#ffffff"
                                   BorderWidth="1px" BorderColor="#0F517E" Font-Bold="True"></HeaderStyle>
</asp:CommandField>

 

REF:( http://objectmix.com/dotnet/352191-gridview-rowupdating-not-firing.html)

( http://www.codenewsgroups.net/group/microsoft.public.dotnet.framework.aspnet.webcontrols/topic15667.aspx )

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.