【发布时间】:2013-10-21 12:29:25
【问题描述】:
我有一些用于输入搜索值的文本框。我有一个存储过程,它有 2 个日期时间、1 个 int 和 1 个 char 参数。我将SqlDataSource 附加到TextBox 并将默认值设置为null,但是当我运行我的项目时,将空值传递给存储过程,但我的存储过程需要一个空值。如何在 SqlDataSource 绑定到文本框的情况下传递 null?
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DB_MosquesAffairsConnectionString3 %>"
SelectCommand="mqa.S_Conference_Select_Date"
SelectCommandType="StoredProcedure" onload="SqlDataSource1_Load"
onselecting="SqlDataSource1_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" DbType="Date" DefaultValue="null"
Name="StartDate" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DbType="Date" DefaultValue="null"
Name="EndDate" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox3" DefaultValue="null"
Name="ConferenceName" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBox4" DefaultValue="null"
Name="ConferenceID" PropertyName="Text" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
【问题讨论】: