473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 7323
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.com> wrote in message
news:OW**************@TK2MSFTNGP11.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**************@TK2MSFTNGP12.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.com> wrote in message
news:OW**************@TK2MSFTNGP11.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.Collections and
System.Collections.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
StringDictionary and use ContainsKey() method to check if an item is already
in the dictionary.

For case insensitive matches, you can try CaseInsensitiveHashCodeProvider
class.

-vJ
"Seelan" <as**@asas.com> wrote in message
news:u6*************@tk2msftngp13.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**************@TK2MSFTNGP12.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.com> wrote in message
news:OW**************@TK2MSFTNGP11.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
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...
1
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...
7
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...
0
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. ...
1
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...
0
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...
0
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.