Solved

ASP.NET Dropdown list

Posted on 2015-01-27
4
110 Views
Last Modified: 2015-01-27
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.
0
Comment
Question by:RadhaKrishnaKiJaya
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 40573720
Try:

If Reader.Item("Active") = "Y" Then
                ddlCustActive.SelectedValue = "Yes"
Else
               ddlCustActive.SelectedValue = "No"
 End If
0
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 40573728
Use the FindByText option:
ddlCustActive.Items.FindByText("Yes").Selected = true
0
 

Author Comment

by:RadhaKrishnaKiJaya
ID: 40573925
Thank you for your reply. But neither of the solution is working.
0
 

Author Closing Comment

by:RadhaKrishnaKiJaya
ID: 40573962
I changed the code little bit and it worked.

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

Thank you so much for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now