Reputation:
I am new in ASPNET. I am having a problem returning a default value for a dropdownlist. When a user select another value for example
(Names- Value)Private - 1; Friends - 2; Public - 3; (not binded to database but hard coded)
When a user select a value and saved it to a database. How can I return a new dafault value for a dropdown?
I tried
dropdownlist1.selectedvalue = 2 (code behind)
and still the dropdownlist view Private instead of Friends.
What will be the solution to this scenario? Please help
Kind Regards Jake
Upvotes: 0
Views: 485
Reputation: 395
This is entirely from my memory, but I believe that ".SelectedValue" actually requires the value, not the index. So you could try dropdownlist1.selectedvalue="Friends - 2"
. Or you could try dropdownlist1.items.findbyvalue("Friends - 2")
in combination with dropdownlist1.selectindex()
. Hope some part of that helps!
Upvotes: 0