Shamim
Shamim

Reputation: 383

how to set the dropdownlist selected value

work on C# asp.net vs05 .I have a ddl,ddl contain five element

ddl values are 
1
2
3
4
5

From the database i get 1,Need to show selected value is 1 .How to show ddl Selected value is 1.

Upvotes: 0

Views: 1055

Answers (2)

rslite
rslite

Reputation: 84843

Try to set ddl.SelectedValue to the value of the item you want to select. If that doesn't work try this (where you replace 0 with the index of the element you need to select):

ddl.Items[0].Selected = true;

Upvotes: 2

ccalboni
ccalboni

Reputation: 12520

What about .SelectedValue property?

MSDN, DropDownList class members

Upvotes: 0

Related Questions