简体   繁体   English

SqlDataSource onSelected 事件未触发

[英]SqlDataSource onSelected event not firing

I have an SqlDataSource control with a selectcommand that doesn't fire onselected event (while another one, very similar, fires it).我有一个带有 selectcommand 的 SqlDataSource 控件,该控件不会触发 onselected 事件(而另一个非常相似的事件会触发它)。 The one that doesn't fire:不火的那个:

<asp:SqlDataSource ID="CommunicationSQLDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:aspnet-WebApplication6-20131007103938ConnectionString1 %>" 
    SelectCommand="SELECT * FROM tCommunication" OnSelected="CommunicationSQLDataSource_Selected">
     <SelectParameters>
        <asp:Parameter Type="String" Name="ProjectID"></asp:Parameter>
    </SelectParameters>
</asp:SqlDataSource>

(The one that fires, just for reference) (火的那个,仅供参考)

<asp:SqlDataSource ID="DetailsSQLDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:aspnet-WebApplication6-20131007103938ConnectionString1 %>"
    SelectCommand="SELECT [ProjectID], ..." OnSelected="DetailsSQLDataSource_Selected">
    <SelectParameters>
        <asp:Parameter Name="ProjectID" Type="Object" />
    </SelectParameters>
</asp:SqlDataSource>

What I see is that the debugger doesn't reach the block of CommunicationSQLDataSource_Selected even though it is referenced in the control.我看到的是调试器没有到达 CommunicationSQLDataSource_Selected 块,即使它在控件中被引用。

be sure you Use it in Form tag or asp:Content ..upon which Environment used确保在 Form 标签或 asp:Content ..on which Environment 中使用它

<form id="form1" runat="server">
<asp:SqlDataSource ID="DetailsSQLDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:aspnet-WebApplication6-20131007103938ConnectionString1 %>"
    SelectCommand="SELECT [ProjectID], ..." OnSelected="DetailsSQLDataSource_Selected">
    <SelectParameters>
        <asp:Parameter Name="ProjectID" Type="Object" />
    </SelectParameters>
</asp:SqlDataSource>
  </form>

I solved it.我解决了。 I clicked config.我点击了配置。 data source, and walked through the wizard without changing anything.数据源,并在不更改任何内容的情况下完成向导。 Thanks for all.谢谢大家。

将 CancelSelectOnNullParameter 属性设置为 false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM