Solved

dropdown list select value

Posted on 2009-05-14
10
196 Views
Last Modified: 2013-12-17
I have a dropdown list which I want to force it to select a specific value, is this possible.
0
Comment
Question by:Mr_Shaw
  • 5
  • 3
  • 2
10 Comments
 
LVL 16

Expert Comment

by:ToddBeaulieu
ID: 24385046
Sure. Set the SelectedIndex, or find the item and set it's Selected property = True.
0
 

Author Comment

by:Mr_Shaw
ID: 24385070
There is no selected properted for a dropdown list. Please could you give me an example.
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24385081
if data is already bound to dropdownlist hten ddlist.selectedindex = index  
0
 

Author Comment

by:Mr_Shaw
ID: 24385114
I am binding the data from a database so I am not sure of the index value of the item i want to select.
0
 
LVL 16

Accepted Solution

by:
ToddBeaulieu earned 250 total points
ID: 24385166
Selected is an ITEM property. See, this all depends on what you're really trying to accomplish, so it's hard to guess from the original question.

If you know what the text is, you probably need to find the item and either set it to be selected or set the dropdown's selectedindex property = the item's index.

Here's an example:

http://answers.yahoo.com/question/index?qid=20070514035103AA1v20M
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Assisted Solution

by:srikanthreddyn143
srikanthreddyn143 earned 250 total points
ID: 24385218
try it

DropDownList.SelectedValue = "somevalue"



0
 

Author Comment

by:Mr_Shaw
ID: 24385298
I need the code to actually selct not just highlight the item in the list.
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24385359
DropDownList1.Items.FindByText("text here").Selected=true;
DropDownList1.Items.FindByValue("value here").Selected = true;
0
 

Author Comment

by:Mr_Shaw
ID: 24385751
Ok thanks guys for your help.

I figured out the last part of the problem was the order in which I was calling my stored procedures.

I will dish out the point soon.

Thanks
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31581448
thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 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

18 Experts available now in Live!

Get 1:1 Help Now