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}')">

<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"/>

  • This question might be more appropriate on Stack Overflow since it's a developer question than a front-end, HTML/CSS/JavaScript issue. Josh Mock about 9 years ago

1 answer


Looks like your problem is in the following query:

sermon_speakerfirst + ' ' + sermon_speakerlast

That should be something like:

sermon_speakerfirst, sermon_speakerlast

Look and see if you're getting database errors on that. If you do post on SO, include the errors ;)

Answered about 9 years ago by Brian Hicks