473,659 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing duplicates from a DropdownList

In your query use DISTINCT
SELECT DISTINCT CITY FROM <tablename> WHERE STATE='<state
name>'. This will bring only one of each city from the
table.

-----Original Message-----
I'm getting a list of addresses from a database and binding them to adatagrid. I have a dropdown list that allows the user select a particularstate. The event updates the query to only fetch the slected state. Afterthat I'd like to populate a seperate DropdownList that allows the user tosee a selected city. So when I bind the data the code looks like this:
public void BindGrid()
{
UpdateSelectStm t();
adptr_LocationS ummary.Fill(dsL ocationSummary1 );
//CityChooser is a DropdownList
CityChooser.Dat aSource = dsLocationSumma ry1;
CityChooser.Dat aTextField = "City";
CityChooser.Dat aValueField = "City";
CityChooser.Dat aBind();
//ListItemCollect ion cities = CityChooser.Ite ms;
//do something here to remove duplicates
dg_LocationSumm ary.DataBind();
}

Now the problem is that the CityChooser is getting a city for every row, butwhat I'd like is to show only unique cities. I couldn't find a flag forgetting only unique items. I can seem to think of a clean, efficient, way toremove all the duplicates without copying the items into a new list andbinding (though it wouldn't technically be binding I suppose) theCityChooser to the new list.

Thanks

Brian
.

Nov 17 '05 #1
0 2578

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3668
by: Iain | last post by:
Hi I have inherited a web app with the following table structure, and need to produce a table without any duplicates. Email seems like the best unique identifier - so only one of each e-mail address should be in the table. Following http://www.sqlteam.com/item.asp?ItemID=3331 I have been able to get a duplicate count working: select Email, count(*) as UserCount
20
3330
by: Rubinho | last post by:
I've a list with duplicate members and I need to make each entry unique. I've come up with two ways of doing it and I'd like some input on what would be considered more pythonic (or at least best practice). Method 1 (the traditional approach) for x in mylist: if mylist.count(x) > 1:
6
3467
by: M B HONG 20 | last post by:
Hi all - I was wondering if Javascript has a way to easily remove duplicates from a string. For example, if I had a string: "car truck car truck truck tree post post tree" it should turn into: "car truck tree post"
4
3618
by: Drew | last post by:
I have a permission tracking app that I am working on, and I have made the insert page for it. I am having issues on how to prevent duplicates from getting entered. Currently the interface for the app has a mixture of select boxes, list boxes and checkboxes. The form submits the page to processAIMR.asp and then does the inserting. I am using a loop to insert a new record for each checkbox checked or listbox entry selected. My...
16
4168
by: tyrfboard | last post by:
I've been searching for awhile now on how to remove duplicates from a table within an Access db and have found plenty of articles on finding or deleting duplicates. All I want to do is remove them from within an SQL query - leaving one of the records behind of course. I have a mailing list comprised of a union query that gets records from two separate tables. I want to be able to run a query that removes one (or more) of the duplicated...
2
4873
by: Milsnips | last post by:
hi there, i have the following HTML code: -------------------------- <asp:DropDownList id="hddList" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item 2</asp:ListItem> <asp:ListItem Value="3">Item 3</asp:ListItem> <asp:ListItem Value="4">Item 4</asp:ListItem> <asp:ListItem Value="5">Item 5</asp:ListItem>
2
2681
by: sjlung | last post by:
I apologise if this is a trivial question but I have appended three tables in access and within this table, there are duplicate entries. I have tried to set my reference number for this table to be a primary key to ensure duplicates are no longer shown but this changes itself as soon as the tables are all appended together. I appreciate any help you can give me. Thanks alot.
7
3362
by: vsgdp | last post by:
I have a container of pointers. It is possible for two pointers to point to the same element. I want to remove duplicates. I am open to which container is best for this. I thought of using std::set, but my elements do not have a '<' operator, as it does not make sense. I could add an integer index to the data structure so that each element has a unique index associated with it and then override '<' to sort by index, but I am not...
4
13958
by: Mokita | last post by:
Hello, I am working with Taverna to build a workflow. Taverna has a beanshell where I can program in java. I am having some problems in writing a script, where I want to eliminate the duplicates in an array (String). for (int k=0; k<myLength; k++){ boolean isthere=false; for (int l=0; l<sizeres; l++){ if (res.equals(my)){
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8339
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.