Solved

ASP.NET Dropdown list

Posted on 2015-01-27
4
109 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 33

Expert Comment

by:paulmacd
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

22 Experts available now in Live!

Get 1:1 Help Now