Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2008-06-12
2
Medium Priority
?
1,325 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
[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 Comments
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

648 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