Solved

How do I programmatically  select a specific items from my dropdown list.

Posted on 2010-09-01
2
294 Views
Last Modified: 2013-12-17
I have a DropdownList1 it uses sqldatasource1 to get the states but I want the first state on pageload to be MN.  How do I get it to show MN?  MN is item 6 in the db.

This is what I have now:

if (!IsPostBack)
        {
            string x = "6";
            x = DropDownList1.SelectedItem;
        }
0
Comment
Question by:bmanmike39
2 Comments
 
LVL 7

Accepted Solution

by:
jdavistx earned 500 total points
ID: 33582718
DropDownList1.SelectedIndex = 5;
0
 

Author Closing Comment

by:bmanmike39
ID: 33582764
Thanks!
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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