Solved

Group options in DropDownList

Posted on 2006-06-26
1
1,206 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

15 Experts available now in Live!

Get 1:1 Help Now