Click here to Skip to main content
15,891,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hye all..

I am using this code to display the selecteditem of the dropdownlist from the label.text

C#
Me.ddlDefect.SelectedItem.Text = Me.lblDefect.Text

the text in the label is:

C#
Me.lblDefect.Text = "DAKON"


This is the ddlDefect items that appears in my dropdownlist:

DAKON(as the selecteditem)
ANA ARAI
DAKON
DAKON/DENTED
DAN
DAN AT ASSY PTS
DAN AT DIA. 104.8

Note that DAKON appears two times; first as the selecteditem n the other one as the dropdownlist items.

The items that I want to display is only dropdownlist items and the selecteditem is DAKON, not adding the DAKON item to the first item in dropdownlist.

How can I do that?
Posted
Updated 17-May-12 21:33pm
v4

1 solution

Try this:
C#
ddlDefect.SelectedValue = lblDefect.Text;
 
Share this answer
 
Comments
snamyna 18-May-12 3:42am    
lblDefect.Text is DAKON and ddlDefect.SelectedValue is 194. It is impossible for the dropdownlist to display the data that is not in the list. Am I right?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900