I gave up. In addition toFilterExpression
and FilterParameters, I tried SelectParameters
with the same results. I decided to just hard code the whole SelectCommand
every time. Parameters just don't work. I've always hated them because they simply to not handle NULLs well. During my diagnosis, I even ran SQL Server Profiler to trace communication from Visual Studio and when the parameter wasn't used (i.e. the "ISNULL" part was used), the query was never even submitted to the SQL server. I ended up using the following code instead:
<asp:SqlDataSource ID="dsIAMS" runat="server" ConnectionString="<%$ ConnectionStrings:ReportsConnectionString %>" />
dl = (DropDownList)tFilters.Controls[0];
// dl.ID = dlPASUBTYPENAME
if (dl.SelectedItem.Text == "") {
dsIAMS.SelectCommand+=dl.ID.Substring(2) + " IS NULL";
}
else {
dsIAMS.SelectCommand+=dl.ID.Substring(2) + "='" + dl.SelectedItem.Text + "'";
}