【问题标题】:What happens between DataBinding and DataBound?DataBinding 和 DataBound 之间会发生什么?
【发布时间】:2022-01-16 04:49:42
【问题描述】:

在我的 WebForms 应用程序中,我有一个下拉列表 (DDL),其中包含方法 Method_DataBindingMethod_DataBound。当我用这个 DDL 打开表单并且它有一些错误的数据时,它给了我一个例外。我想抓住它,但我不明白,在哪里做。

在方法Method_DataBinding 的最后一行没有错误,也没有到达Method_DataBound,所以错误介于这两个方法之间。我不明白在哪里

<asp:DropDownList
    ID="SomeId"
    runat="server"
    DataSourceId="SomeDsId"
    OnDataBinding="Method_DataBinding"
    OnDataBound="Method_OnDataBound" />

protected void Method_DataBinding()
{
}

// Here betwen this two methods I have error, can't catch it

protected void Method_DataBound()
{
}

【问题讨论】:

标签: c# asp.net .net webforms


【解决方案1】:

如果您使用SqlDataSource(EntityDataSourcesimilar),您可以使用Updated event

protected void SomeDsId_OnUpdated(object sender, SqlDataSourceStatusEventArgs e)
{
   if (e.Exception != null) 
   {
         // handle here
   }
}

【讨论】:

    猜你喜欢
    • 2012-10-11
    • 2015-02-13
    • 1970-01-01
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-24
    • 2021-09-20
    相关资源
    最近更新 更多