Click here to Skip to main content
13,259,194 members (50,850 online)
Rate this:
Please Sign up or sign in to vote.
See more:
good evening,

when i am binding dropdown to the database, one dropdownlist item repeats two times.

please help me.

thank you.
Posted 27-Feb-13 1:25am
kishore Rajendran 27-Feb-13 6:37am
please post your code
Member 9567873 27-Feb-13 6:55am
this is my code

public void DropDownFill()
ItemManagementDetails itemDetails = new ItemManagementDetails();
ListItemForDropDown list = new ListItemForDropDown();
InventoryClient objService = new InventoryClient();

list = objService.FillDropDownStore();
ddlStoreId.DataSource = list.List.OrderBy(x => x.Text);
ddlStoreId.Items.Insert(0, "--Select --");

Member 9567873 27-Feb-13 6:59am
I have posted the code please see the code and please help me
Matej Hlatky 27-Feb-13 7:03am
Have you tried to use DISTINCT statement / Distinct() Linq extension method?
Member 9567873 27-Feb-13 7:08am
no i have not used please tell me how to use it
Matej Hlatky 27-Feb-13 7:09am
Just add Distinct() at the end of your linq methods: ddlStoreId.DataSource = list.List.OrderBy(x => x.Text).Distinct();
Member 9567873 27-Feb-13 7:15am
i have added .Distinct() but it is not working.
Rai Pawan 27-Feb-13 7:19am
It pretty much seems to be the case where your method titled DropDownFill is being called twice. Probably at page_load event and on some other event. Try to debug the method, check whether it is getting called twice.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Check what your query returns, maybe its in there 2 times
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

there is some issue in your code check it painfully, otherwise following code you can use.
this.drpDown.DataSource = dt;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100