Your daily dosage of Asp.Net knowledge - 100% pure and additive free!
Navigation:
Home
|
All FAQ Categories
|
All FAQs
|
Top 10 FAQs
|
Most Viewed FAQs
|
Suggest new FAQ
|
Links
Main Categories:
› General
(9)
› Beginner
(39)
› ASP.NET AJAX
(8)
› C#
(13)
› LINQ
(1)
› Configuration
(10)
› Session
(4)
› WebForms
(12)
› Controls
(14)
› Caching
(1)
› Database
(1)
Visitors Online:
36
Main FAQ Category:
Controls (14)
Also in:
Beginner
(39)
WebForms
(12)
How to programmatically select a value in DropDownList Control in ASP.NET?
Posted: 20-Apr-2008
Updated: 20-Apr-2008
Views: 40752
I know this FAQ sounds ridiculous and that the answer is pretty obvious but i have discovered that not all beginner ASP.NET developers know that
SelectedValue
property of DropDownList control can be used not only to retrieve the value of the item that is currently selected but also to set the selected item of the DropDownList.
So for those of you which did not know this, If you have a (amongst other) item in your control with value "3", this line of code will make that item selected in your DropDownList control:
DropDownList1.SelectedValue =
"3"
;
Found errors in this FAQ? Have a suggestion? Click
here
Printer Friendly version of this page
(Current rating:
3.27
out of 5 for 11 votes)
Show Comments (1)
Loading Comments. Please Wait...