我有一個asp.net c#網站,我正在用Visual Web Developer Express Edition 2010進行開發。在這個網站中,我有一個FilterExpression,它應該過濾三個標準:開始日期,結束日期和關鍵字搜索。FilterExpression問題 - 多個條件
我能夠獲得自己開始和結束日期過濾器的工作,並且關鍵字搜索也是獨立工作的。我遇到的麻煩是讓所有三個人一起工作。
我使用(見下文)的代碼在默認情況下(良好)顯示所有記錄,確實想篩選時,以下幾點:
- 搜索關鍵字:所有記錄
- 搜索關鍵字以及日期範圍:沒有記錄
- 只是日期範圍:所有記錄
下面的代碼我現在有,它會嘗試所有這三個整合,但不起作用。任何意見將是有益的:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:sermonConnectionString %>"
SelectCommand="SELECT ID, sermon_date, sermon_speakerfirst + ' ' + sermon_speakerlast AS Speaker, sermon_title, sermon_subtitle, sermon_notes FROM what ORDER BY sermon_date DESC"
FilterExpression="([sermon_title] LIKE '%{0}%') AND ([sermon_date] >= '{1}' AND [sermon_date] <= '{2}')">
<FilterParameters>
<asp:ControlParameter ControlID="TextBox2" PropertyName="Text" Type="DateTime" ConvertEmptyStringToNull="true" />
<asp:ControlParameter ControlID="TextBox3" PropertyName="Text" Type="DateTime" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter ControlID="SermonSearch" PropertyName="Text" Type="String"/>
</FilterParameters>
</asp:SqlDataSource>
請保持像「Asp.net C#」標記出你的標題 - 只使用標籤這一點。 – 2010-08-03 19:18:44