prevent duplicates in a data column

  • Thread starter Thread starter afsheen
  • Start date Start date
A

afsheen

Hi

Iam retreiving a Dataset from a webservice into my web application. I have
to populate a dropdown web control with it but my problem is that the column
of countries that i want to populate the dropdown list has duplicate values
...... how can i prevent that from appearing in a dropdownlist bounded to the
dataset without making changes in the sql data retrival select statement in
my webservice code......

thanks
Afsheen
 
You can create a DataColumn and create it as a primary key to a temporary
table. Then, iterate through the table that's returned from your SQL
Statement and on the Rows.Add(givenDataRow) trap the exception that will be
thrown invariably when you try to add a non-unique column - then just ignore
it.

This isn't very elegant, but if you don't want to touch your SQL Statement
(maybe though, it might work to select Distinct from another query?) I think
you are going to have to use some sort of implementation where you populate
some data structure with the unique values and then add them to your
combobox.

HTH,

Bill
 
Back
Top