Last post Mar 21, 2008 08:19 AM by WayneLigon
Mar 20, 2008 10:32 AM|WayneLigon|LINK
I have the following three cascading dropdownlists on the form:
The Regons DDL
The COUNTIES in that REGION
And the ASSETS in that COUNTY
Now, in the second DDL, I cheat; the list of counties isn't going to change, so there is an entry for 'All' in the county listings with a budgetcode + wildcard hardcoded in there. Works perfectly.
What I need is to populate a gridview with either the records for a single asset for that county, or all assets for that county. So far I have:
Now, the original line was this, and it worked perfectly but of course doesn't work for the ALL condition.
The SELECT command up there just flat is not working and I can find zero help on how it should work. I've tried... a lot of variations on it, the ListItem and such, all to no avail. \
The upshot is: if I choose the ALL item, I should see all the records for every asset in that county, as if I'd stopped at the second dropdownlist.
Mar 20, 2008 10:45 AM|BlogPortalist|LINK
Perhaps something like:
SELECT [a bunch of fields] FROM [WexData] WHERE ([Asset] like @asset OR @asset='All')
Mar 20, 2008 11:26 AM|WayneLigon|LINK
No, that doesn't work, It doesn't crash, but it brings back all the asset numbers instead of just all the asset numbers for the previously-chosen budget code.
Basically, what I need is the TRANSACT-SQL way of saying
SELECT * from table where DEPT = ?
SELECT * from table where ASSET = ?
Mar 20, 2008 03:49 PM|BlogPortalist|LINK
Aha, ok. Then it would be:
SELECT [a bunch of fields] FROM [WexData] WHERE ([Asset] = @asset AND @asset<>'All') OR (@asset='All' AND DEPT = @dept)
Mar 20, 2008 04:02 PM|WayneLigon|LINK
No value given for one or more required parameters.
Mar 20, 2008 04:59 PM|Mikesdotnetting|LINK
You need to add @dept to the parameters collection of the datasource control. Make sure it is added after the first one. They need to be added in the order they appear in the SQL.
Mar 21, 2008 08:19 AM|WayneLigon|LINK
That appears to work, Thank you very much!