Solved

Group options in DropDownList

Posted on 2006-06-26
1
1,222 Views
Last Modified: 2012-08-13
Hi,

I have a DropDownList that draws its data from a DataSet. The field I'm pulling from the dataset has duplicates, and unless I group them, I get duplicates in the DropDownList.

How do I group the data in the DropDownList?


Here's my current code on the Page_Load event:

        If Not Page.IsPostBack Then
            SqlDataAdapter1.Fill(DataSet1)
            DropDownList1.DataSource = DataSet1
            DropDownList1.DataTextField = "LOBLab"
            DropDownList1.DataValueField = "LOBID"
            DropDownList1.DataBind()

            DataView1 = DataSet1.Tables(0).DefaultView
            DataView1.Sort = "ProductLab"
            DataGrid1.DataSource = DataView1
            DataGrid1.DataBind()
        End If

0
Comment
Question by:LoveToSpod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
Collindsouza earned 500 total points
ID: 16983129
While grouping or querying a dataset is not possible in a DropDownList..

You will have to amend your SQl Query to return only Distinct records..

By Using SELECT DISTINCT Keyword..

So your Query will be as follows

SELECT DISTINCT * from TABLE
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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