web app - Sorting dropdownlists/datasets

Posted on 2004-10-28
Last Modified: 2010-04-23

     I have:

1 dropdownlist called cmbSearchBy with two options: Nomenclature and Item ID
2 dropdownlists called cmbSearch1 and cmbSearch2, where 1 is bound to Nomenclature and 2 is bound to ID in the dataset that comes from the products table

Nomenclature (cmbSearch1) is in alphabetical order - when cmbSearchBy is used to choose Item ID, and cmbSearch1 disappears and cmbSearch2 appears, I want the Item IDs to all be listed in numerical order, and back to alphabetical when switched back.  I don't know how to do this - do I need to use something like a dataview?  If so, code?  Currently they both list by the way the select statement ordered the dataset (by nomenclature)


Question by:gleznov
    LVL 4

    Accepted Solution

    I would use 2 dataviews (one for each combo):

    dim dv as new DataView(yourDataSet.Tables("TheNameOfYourTable"))

    and then, set the sort property:

    dv.Sort = "TheNameOfTheColumn"

    and then set the dataSource property of your combos to the dataView and set the DislplayMember property (I can't remember wich is that property in the web, but if you see all of them you will recognize it)

    Author Comment

    Thanks!  And thanks for the clarity of your answer :)

    LVL 4

    Expert Comment

    Is good to know that my answer could help you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This video discusses moving either the default database or any database to a new volume.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now