Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET Dropdown list

Posted on 2015-01-27
4
Medium Priority
?
119 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 27

Accepted Solution

by:
Shaun Kline earned 1500 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

661 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