Solved

Group options in DropDownList

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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 short film showing how OnPage and Connectwise integration works.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

19 Experts available now in Live!

Get 1:1 Help Now