473,809 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Distinct values in Dropdown LIST

Hey Guys,
I have read a table from SQL Server to a Dataset called ds. Now I want
to list the items of one column to a DropDown List...I can do this perfectly
but i want ht e list to contain DISTINCT items without having to call the
SQLCommand again!
Please help thanks!
Seelan-
Nov 16 '05 #1
3 7365
You can use FindStringExact to find the text of your item and not add them
if it's already there.

Or if you have a ton of items and don't want to have the perf hit, you could
create a hash table; check against the hash table before adding to the list
and populate it as you fill the list.

HTH

-vJ

"Seelan" <as**@asas.co m> wrote in message
news:OW******** ******@TK2MSFTN GP11.phx.gbl...
Hey Guys,
I have read a table from SQL Server to a Dataset called ds. Now I want
to list the items of one column to a DropDown List...I can do this
perfectly
but i want ht e list to contain DISTINCT items without having to call the
SQLCommand again!
Please help thanks!
Seelan-

Nov 16 '05 #2
Can u explain how to create hash tables please? Im kind of new here...

"Vijaye Raji" <no************ *@hotmail.com> wrote in message
news:#U******** ******@TK2MSFTN GP12.phx.gbl...
You can use FindStringExact to find the text of your item and not add them
if it's already there.

Or if you have a ton of items and don't want to have the perf hit, you could create a hash table; check against the hash table before adding to the list and populate it as you fill the list.

HTH

-vJ

"Seelan" <as**@asas.co m> wrote in message
news:OW******** ******@TK2MSFTN GP11.phx.gbl...
Hey Guys,
I have read a table from SQL Server to a Dataset called ds. Now I want to list the items of one column to a DropDown List...I can do this
perfectly
but i want ht e list to contain DISTINCT items without having to call the SQLCommand again!
Please help thanks!
Seelan-


Nov 16 '05 #3
There're a few choices in the System.Collecti ons and
System.Collecti ons.Specialized namespace. If you want only to check if the
object has been added or not, you could use GetHashCode() method in the
string that you're adding and throw it into a sorted array. That way you
will be comparing integers instead of strings (which is way more faster).

Or if you want to get back to the original object, you can use
StringDictionar y and use ContainsKey() method to check if an item is already
in the dictionary.

For case insensitive matches, you can try CaseInsensitive HashCodeProvide r
class.

-vJ
"Seelan" <as**@asas.co m> wrote in message
news:u6******** *****@tk2msftng p13.phx.gbl...
Can u explain how to create hash tables please? Im kind of new here...

"Vijaye Raji" <no************ *@hotmail.com> wrote in message
news:#U******** ******@TK2MSFTN GP12.phx.gbl...
You can use FindStringExact to find the text of your item and not add
them
if it's already there.

Or if you have a ton of items and don't want to have the perf hit, you

could
create a hash table; check against the hash table before adding to the

list
and populate it as you fill the list.

HTH

-vJ

"Seelan" <as**@asas.co m> wrote in message
news:OW******** ******@TK2MSFTN GP11.phx.gbl...
> Hey Guys,
> I have read a table from SQL Server to a Dataset called ds. Now I want > to list the items of one column to a DropDown List...I can do this
> perfectly
> but i want ht e list to contain DISTINCT items without having to call the > SQLCommand again!
> Please help thanks!
> Seelan-
>
>



Nov 16 '05 #4

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

Similar topics

5
3472
by: Nick Calladine | last post by:
Learning : Loop to list all dropdown box values on a form Can some one point me in the right direction : I have a form which I want to loop through I basically want to get all the selected values of the option tag see example below
1
3139
by: Les Juby | last post by:
Simple problem that's stumping me at present.! We have created a data capture form in Access 97 which uses a dropdown list which has been populated from a table. The dropdown list displays the values from Field-A but there is also an ID value associated with each record which will not be displayed to the person filling in the form. But when we take the contents of the form to add it as a new record in another table, we want to add the...
7
23530
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking for a match between cVal and the selectedValue then stop when I do have a match the obvious problem is that each iteration fires the selectedIndexChanged but also for a large list this will slow everything down. There must be a better way int...
0
1646
by: Jeff | last post by:
After I bind the repeater control in the form_load event, it builds multiple lines based on the number of rows in the dataset. In the repeater control, I have a textbox and a dropdown list box. I have tied the "SelectedIndexChanged" to it. At runtime - after I change the dropdown box selection, I'm only able to view the values of the controls within that one repeater instance. After the dropdown selection is changed, I need to...
1
2608
by: Sean | last post by:
Hi, I am facing a problem and would like to know whether it is possible to do so. i am retrieving a refcursor which has a list of last names, first names, address, city, state, and zip. I pick up this information and populate a dropdown list. I was wondering if it is possible to pick up distinct records, and sort them out by last name? Suggestions are welcomed.
0
1269
by: Kay | last post by:
Hello, I have developed a web custom control, I want one of the properties of the control to appear as a dropdown list so the user can select from the list. My question is: how do I define an editor to fill up the dropdown list, so far I have the following code which displays the property as a dropdown but I do not know how to get values it to it, I have only 3 values. Public Class EntryModeEditor Inherits...
0
1244
by: Kay | last post by:
Hello, I have developed a web custom control, I want one of the properties of the control to appear as a dropdown list so the user can select from the list. My question is: how do I define an editor to fill up the dropdown list, so far I have the following code which displays the property as a dropdown but I do not know how to get values it to it, I have only 3 values. Public Class EntryModeEditor Inherits...
1
2269
by: assgar | last post by:
Hi I need help solving a porblem. I have a form that displays a checkbox, service code, description and dropdown with fees on each row. The fee_money and unit array only returns a selected value from the first item (checkbox).
0
9721
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
10639
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
10376
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...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
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
9200
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
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
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
3861
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.