Selecting an item in a DropDownList

Posted on 2007-04-09
Last Modified: 2010-04-15
OK, this should be simple enough but I can't seem to solve it. I need to programmatically set the selected item of a dropdownlist control if I know the value. I understand I can use DropDownList1.Items.FindByValue("1") to return the ListItem itself. What I need to do is make sure that is the selected item. Can anyone help?
Question by:Russ Suter

Accepted Solution

CBeach1980 earned 125 total points
ID: 18878903
DropDownList1.Items.FindByValue("1").Selected = true

Expert Comment

ID: 18881404

You have to write in the select indexchanged event like below
drpList.Items.FindByValue("1").Selected = true

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
This article will show, step by step, how to integrate R code into a R Sweave document
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

13 Experts available now in Live!

Get 1:1 Help Now