Solved

ASP.NET Dropdown list

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 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