Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Binding Data to DropDown List from Database in Alphabetical order

Binding Data to DropDown List from Database in Alphabetical order

Scheduled Pinned Locked Moved ASP.NET
helpdatabasewpfwcfadobe
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pavanip
    wrote on last edited by
    #1

    Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown lists one dropdown contains A to Z list like A,B,C,D..Z. 2nd list contains above items like All,Air,Books.Now I want that when I select A from A-Z list it will display A items in alphabetical order and the Top item should be "All" after that remaining items.But if I display items in alphabetical order All is displaying like Air,Airline,All.Can anybody help me to resolve the problem. Thanks in advance Pavani

    C B S 3 Replies Last reply
    0
    • P pavanip

      Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown lists one dropdown contains A to Z list like A,B,C,D..Z. 2nd list contains above items like All,Air,Books.Now I want that when I select A from A-Z list it will display A items in alphabetical order and the Top item should be "All" after that remaining items.But if I display items in alphabetical order All is displaying like Air,Airline,All.Can anybody help me to resolve the problem. Thanks in advance Pavani

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      So you can't sort alphabetically, you have to provide your data sorted in the order you want.

      Christian Graus Driven to the arms of OSX by Vista.

      1 Reply Last reply
      0
      • P pavanip

        Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown lists one dropdown contains A to Z list like A,B,C,D..Z. 2nd list contains above items like All,Air,Books.Now I want that when I select A from A-Z list it will display A items in alphabetical order and the Top item should be "All" after that remaining items.But if I display items in alphabetical order All is displaying like Air,Airline,All.Can anybody help me to resolve the problem. Thanks in advance Pavani

        B Offline
        B Offline
        BalasubramanianK
        wrote on last edited by
        #3

        U have to use "Order by" clasue. Each and every change event of your drop down list, you have to change your query to bind data.....

        Balasubramanian K.

        P 1 Reply Last reply
        0
        • B BalasubramanianK

          U have to use "Order by" clasue. Each and every change event of your drop down list, you have to change your query to bind data.....

          Balasubramanian K.

          P Offline
          P Offline
          pavanip
          wrote on last edited by
          #4

          Thanks for your response. I already used order by clause to display in alphabetical order.Then it looks like Air,Airline,All.When we select alphabets A-Z i want to display first All and after that remaining items.Eg if i select A it will display All,Air,Airline if i select B it will display All,Books,Bank etc.All should be at top position.

          B 1 Reply Last reply
          0
          • P pavanip

            Thanks for your response. I already used order by clause to display in alphabetical order.Then it looks like Air,Airline,All.When we select alphabets A-Z i want to display first All and after that remaining items.Eg if i select A it will display All,Air,Airline if i select B it will display All,Books,Bank etc.All should be at top position.

            B Offline
            B Offline
            BalasubramanianK
            wrote on last edited by
            #5

            I think that it is not possible if 'All' is in your database. I think that even you cant use "union all" also. Bind data by excluding 'All' and add it. Before adding add 'All' in to your drop down list directly as first index. I think it is possible. Try it.

            Balasubramanian K.

            P 1 Reply Last reply
            0
            • B BalasubramanianK

              I think that it is not possible if 'All' is in your database. I think that even you cant use "union all" also. Bind data by excluding 'All' and add it. Before adding add 'All' in to your drop down list directly as first index. I think it is possible. Try it.

              Balasubramanian K.

              P Offline
              P Offline
              pavanip
              wrote on last edited by
              #6

              Thanks for your suggestion.I tried with that I have so many dropdowns like that and I already saved All in database. Now i need to change for all pages.I will follow your suggestion first i will remove binded "All" from dropdown and i will insert at top position.Thank you.

              1 Reply Last reply
              0
              • P pavanip

                Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown lists one dropdown contains A to Z list like A,B,C,D..Z. 2nd list contains above items like All,Air,Books.Now I want that when I select A from A-Z list it will display A items in alphabetical order and the Top item should be "All" after that remaining items.But if I display items in alphabetical order All is displaying like Air,Airline,All.Can anybody help me to resolve the problem. Thanks in advance Pavani

                S Offline
                S Offline
                Sneha Bisht
                wrote on last edited by
                #7

                HI , in first dropdownlist1 you Bind All Allphabates . in selection of First Dropdownlist you have to Bind Second Dropdownlist with query ; it may be like this . select * from tablename where fieldname like 'dropdownlist1.selectedtext.text%' Try This may be its help .

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups