Multiple select

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    Multiple select

    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

    Code:
    select * from company where industry = ' ' and country = ' ' and province = ' '
    etc

    would i use something like that or a UNION ALL statement.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    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

    Comment

    • OuTCasT
      Contributor
      • Jan 2008
      • 374

      #3
      Originally posted by ck9663
      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.

      Code:
      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))

      Comment

      Working...