Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

ASP.NET Dropdown list

Hi Experts,

How to display a value in the dropdownlist .  I have a dropdown list where I have 2 values. 'Yes' and 'No'. But sometimes I need to display the value from the DB.  Right now I am using this code.

If Reader.Item("Active") = "Y" Then
                ddlCustActive.SelectedItem.Text = "Yes"
Else
               ddlCustActive.SelectedItem.Text = "No"
 End If

It is working. but changing the selected item text in the list and displaying either two 'yes' or two 'no'


Thanks.
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Try:

If Reader.Item("Active") = "Y" Then
                ddlCustActive.SelectedValue = "Yes"
Else
               ddlCustActive.SelectedValue = "No"
 End If
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Thank you for your reply. But neither of the solution is working.
I changed the code little bit and it worked.

ddlCustActive.SelectedValue = ddlCustActive.Items.FindByText("Yes").Value

Thank you so much for your help.