Solved

Group options in DropDownList

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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 …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

17 Experts available now in Live!

Get 1:1 Help Now