当用户选择日期时,我使用 SqlDataSource 控件列出搜索结果,但如果日期为空,则它将列出所有记录。sql命令怎么做?
SELECT Ref_No as name, Job_Order_ID as value
FROM Job_Order
WHERE (Status <> 'JO_Completed') AND (Delivery_Date = @jaDate)
OR (Status <> 'JO_Completed') ORDER BY Ref_No
生成下拉列表的代码
<asp:SqlDataSource ID="NewJobOrderDS" runat="server" SelectCommand="SELECT Ref_No as name, Job_Order_ID as value FROM Job_Order WHERE (Status <> 'JO_Completed') AND (Delivery_Date = @jaDate) ORDER BY Ref_No" OnSelecting="NewJobOrderDS_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="txtJADate2" Name="jaDate" PropertyName="Text" Type="DateTime"/>
</SelectParameters>
</asp:SqlDataSource>