Hello Experts,

I have a dropdown list which is taking information from a database
in which i used as per below

SELECT DISTINCT * FROM [Devices]

but still it shows multiple same values.I want that the values are unique.How should I fix it ?
I already clicked -return only unique raws- under the sql databaseconnection settings still have multiple same values :(

You are performing a select on all fields in the table. A distinct in this case will return rows that are unique, not a particular field.

your drop down control is only using one field from the table so while your SQL distinct is working you still see duplicates in that one field.

So instead, your query should be something like this...

 SELECT DISTINCT field1 FROM [Devices]

wow thanks for the tip,this is the solution :) is there any other easy way for this ?in case that I don't want to create too much accessdatasources for this bindings.

is there any other easy way for this ?in case that I don't want to create too much accessdatasources for this bindings.

I'm not sure what you mean. I assume that what you are working with is a dropdownlist control and you want to populate it dynamically? If that is correct, yes you have to connect this control to a data source just like you did.

If not, you can add the items manually...

<asp:dropdownlist runat="server">
    <asp:ListItem>One</asp:ListItem>
    <asp:ListItem>Two</asp:ListItem>
    <asp:ListItem>Three</asp:ListItem>
</asp:dropdownlist>

if this did not solve your issue, please feel free to post more information.

Your first response solved my problem :) but i created 10 new database connection for each dropdownlist :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.