Solved

ASP.NET - find the index of an item in a dropdownlist given the items value

Posted on 2008-06-12
2
1,300 Views
Last Modified: 2013-11-26
I have a drop-down list on my page that I'm trying to have set to a specific index when the page loads.  The value of one of the items in the drop-down list is being passed into the page.  I'm trying to locate the item in the drop-down list that has that value and set the drop-down list's selected index to be the item that has the value that was passed in.
0
Comment
Question by:josephdaviskcrm
2 Comments
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 500 total points
ID: 21772101
you could put something like this in the pageload.
note: value represents the value passed to the page

Dim value As String = "three"

        DropDownList1.SelectedValue = value

Open in new window

0
 

Author Comment

by:josephdaviskcrm
ID: 21772197
Wow... thats crazy... It works.  I thought that DropDownList1.SelectedValue was a read only value.  I already had it figured out using:
ddlSelectLevel.SelectedIndex = ddlSelectLevel.Items.IndexOf(ddlSelectLevel.Items.FindByValue(Request("WHEREID")))
but using:
ddlSelectLevel.SelectedValue = Request("WHEREID")
is obviously a lot easier.

Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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.

758 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

20 Experts available now in Live!

Get 1:1 Help Now