Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Group options in DropDownList

Posted on 2006-06-26
1
Medium Priority
?
1,228 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

971 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