By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,266 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,266 IT Pros & Developers. It's quick & easy.

Multiple select

OuTCasT
100+
P: 374
Hi.

I have 6 dropdownlist boxes.

Industry
Province
Classification
Status
City
Country

Each of these have a been dynamically bound to a datasource for each of them
I have added a new listitem for each of them for example the first selection for country would be -- Select Country --

Now i need to build a select statement and if the any of the dropdownlist selections are not chosen for instance the country is left on -- Select Country --
then the country should be ommitted from the statement

Expand|Select|Wrap|Line Numbers
  1. select * from company where industry = ' ' and country = ' ' and province = ' ' 
etc

would i use something like that or a UNION ALL statement.
Aug 19 '09 #1
Share this Question
Share on Google+
2 Replies


ck9663
Expert 2.5K+
P: 2,878
You have to check if the object returned the default value. It means it was not modified (clicked). Then you can exclude that on your D-SQL.

Happy Coding!

--- CK
Aug 20 '09 #2

OuTCasT
100+
P: 374
@ck9663
I have bound all the drplists.
And bound the gridview to the controls and this is the code that i have used.

Expand|Select|Wrap|Line Numbers
  1. SELECT  *  FROM [company] WHERE (([country] = CASE WHEN @country IS NOT NULL THEN @country ELSE [country] END) AND ([province] = CASE WHEN @province IS NOT NULL THEN @province ELSE [province] END) AND ([city] = CASE WHEN @city IS NOT NULL THEN @city ELSE [city] END) AND ([industry] = CASE WHEN @industry IS NOT NULL THEN @industry ELSE [industry] END) AND ([companyclassification] = CASE WHEN @companyclassification IS NOT NULL THEN @companyclassification ELSE [companyclassification] END) AND ([status] = CASE WHEN @status IS NOT NULL THEN @status ELSE [status] END))
Aug 20 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.