How dynamically add WHERE clause to sqldatasource

C

Cirene

I have a gridview that is filtered by a databound dropdownlist. I've set
AppendDataBound to True and added the item "ALL" in the dropdownlist.

My gridview is supposed to be filtered by this dropdownlist.

When it's "ALL" I want to include everything. When it's something else I
want to filter the gv data by this dropdownlist.

Do I need to dynamically change the WHERE clause via code? I'm sure there's
an easier way to do this.

Please let me know....

Thanks!
 
L

Larry Bud

I have a gridview that is filtered by a databound dropdownlist. I've set
AppendDataBound to True and added the item "ALL" in the dropdownlist.

My gridview is supposed to be filtered by this dropdownlist.

When it's "ALL" I want to include everything. When it's something else I
want to filter the gv data by this dropdownlist.

Do I need to dynamically change the WHERE clause via code? I'm sure there's
an easier way to do this.

In your 'where' clause, add a parameter of @dropdown (or whatever you
want to call it)...

where (dropdown=@dropdown or @dropdown='All')

What I usually do is if your column that you're querying is an
integer, my default value for the dropdown will be 0 (zero), otherwise
I usually make it ALL or A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top