I have a form that searches for images in a database. I have several DropDownLists with various search criteria e.g. Genus, Photographer, State, Project.
I'd like the user to be able to filter using any combination of these. For example they might pick a specific photographer and a specific genus but choose not filter by project or state.
I'd like to find a good, clean, elegent way to do this.
Here is an example of the code I have now, it has only two possible criteria. It works but I have a feeling there are better ways to do this....
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim thisGenus As String = ddlGenus.SelectedValue
Dim thisDeterminer As String = ddlDeterminer.SelectedValue
Dim whereClause As String
whereClause = "1=1"
If (thisGenus <> "") Then whereClause = whereClause + " AND genus like '" + thisGenus + "'"
If (thisDeterminer <> "") Then whereClause = whereClause + " AND determiner like '" + thisDeterminer + "'"
dsImageList.SelectCommand = "SELECT
View Complete Post