views:

42

answers:

3

Hi

Could anybody help me for avoiding this issue. My issue is that i have one dataset that populates some values like value1, value2, value3, value1, value3, etc. And i am showing this values in a dropdown list. But my requirement is that i have to show the same value once. That is the dropdown should be display like this, value1, value2, value3. Not repeat the existing value. Please help me for implement this. Thanks in advance

+1  A: 

How are you populating the dataset? From a sql query? in memory data source? If SQL, use the DISTINCt keyword.

If in memory, LINQ can perform distinct operations. http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

Jeremy
i am using sql query
Dilse Naaz
+1  A: 

While looping through your data, add to another list/array. If it already exists there, don't add it. Use the resulting list.

Use Distinct if you are using SQL...e.g. Select Distinct column1 from table where...

The Mirage
A: 

using sql or linq use group by.

David