开发者

EntityDataSource Where Clause

开发者 https://www.devze.com 2023-01-29 12:51 出处:网络
I\'m using a EntityDataSource with WhereParameters binded 开发者_如何学编程from DropDownLists. The Where Clause may be something like this: \"it.applicationId = @applicationId\" but in that DropDownLi

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"

0

精彩评论

暂无评论...
验证码 换一张
取 消