Databind ASP.NET List of ListItem to DropDownList issue
I’ve just come across this bizarre thing that I was expecting to work in a different (logical) way, but it doesn’t. Is it a bug or a “feature”?
I’ve just come across this bizarre thing that I was expecting to work in a different (logical) way, but it doesn’t. Is it a bug or a “feature”?
I’m working on an old project written and then patched by several people over the years. At some places they have used SelectedValue property and other places they used SelectedItem.Value.
I am trying to understand the best way of implementing a DropDownList in ASP.NET MVC 2 using the DropDownListFor helper. This is a multi-part question.
I have two models:
I’ve a simple asp.net page (framework 3.5) and an UpdatePanel with a series of dropdownlist I want to populate asyncronously. All works fine in all major browsers (Opera, Safari, IE6, IE7, FF3), but not in Chrome.
My stored procedure is like this
I have a basic DropDownList bound to a ObjectDataSource:
I want to subclass the built-in DropDownList in ASP.NET so that I can add functionality to it and use it in my pages. I tried doing this with a UserControl but found that it doesn’t expose the internal DropDownList (logically, I guess). I’ve googled for the answer but can’t find anything.
I’m looking for a solution to get the first selected item in a DropDownList. And I want to get it when the page loads for the first time.
(Scroll down to bottom of post to find solution.)