Connecting Tech Pros Worldwide Forums | Help | Site Map

Multiple select

OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 361
#1: Aug 19 '09
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.

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Aug 20 '09

re: Multiple select


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
OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 361
#3: Aug 20 '09

re: Multiple select


Quote:

Originally Posted by ck9663 View Post

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

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))
Reply