EntityDataSource Where Clause
I'm using a EntityDataSource with WhereParameters binded 开发者_如何学编程from DropDownLists. The Where Clause may be something like this: "it.applicationId = @applicationId" but in that DropDownList i've created a ListItem with Text="All" Value="".
Of course that when the value is "" i don't want to use that value on the query.
How can i do that?
Thank U All
It looks like there is no design time possibility to use parameters optionally.
Try hooking the Selecting event, like it is described in this question.
In your particular case you can get the selected value of the DropDownList (for example, using the FindControl method) and then simply either pass the value of the parameter, or use the query without a Where clause.
you should at first set the attribute "ConvertEmptyStringToNull" in your parameter to true then type your where condition as follows "@applicationId IS NULL OR it.applicationId = @applicationId"
精彩评论