【问题标题】:Simple Feedback Upon Data Edit on Webform网络表单数据编辑的简单反馈
【发布时间】:2010-09-24 13:20:34
【问题描述】:

我正在使用 GridView 控件,将 Northwind 数据库用作沙箱。

我允许使用 AutoGenerateEditButton="true" 编辑行并且一切正常。我用作参考的书建议使用以下代码进行错误处理(C#):

protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
        if (e.Exception != null)
            this.lblErrorMessage.Text = e.Exception.Message;
    }

我在同一个网络表单上使用了一个简单的 asp 标签。作为一个实验,我将上面的内容编辑为如下所示,因为我想要一个简单的文本确认:

protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
        if (e.Exception != null)
            this.lblErrorMessage.Text = e.Exception.Message;
        else
            this.lblErrorMessage.Text = "Row updated!";
    }

但是,这似乎对我的标签文本没有影响,让我相信异常处理 sn-p 也不起作用。谁能告诉我为什么?

【问题讨论】:

    标签: c# asp.net gridview webforms asp.net-4.0


    【解决方案1】:

    GridView 没有“OnRowUpdated”属性,所以后面的相关代码从未执行过。通过在 asp:GridView 标签中添加 OnRowUpdated="GridView1_RowUpdated" 解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-23
      • 1970-01-01
      • 2016-04-17
      • 1970-01-01
      • 2019-12-16
      • 2016-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多