Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

832 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