Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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