I have an asp.net c# website I'm developing with Visual Web Developer Express Edition 2010. In this website I have a FilterExpression that should filter three criteria: a start date, end date, and keyword search.
I am able to get the start and end date filter working by itself, and also the keyword search is working by itself. What I'm having trouble with is getting all three to work together.
The code I'm using (below) displays all records by default (good) and does the following when trying to filter:
- search keyword: all records
- search keyword plus date range: no records
- just date range: all records
Here's the code I have now, which tries to integrate all three but does not work. Any advice would be helpful:
<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>