Solved

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

Posted on 2008-06-12
2
1,303 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

16 Experts available now in Live!

Get 1:1 Help Now