Sasha
Sasha

Reputation: 20854

Save state for DropDownList after post

i have form with one textbox and dropdownlist

<%=Html.TextBox("Name")%>
<%=Html.ValidationMessage("Name", "Enter name")%>

<%=Html.DropDownList("Not Selected", "DomainID", ViewData["DomainID"])%>


I select value from drop downlist but dont fill name, im getting validation for textbox and then i need select value from dropdown again, of course with textbox it works but what can i do with list??

Upvotes: 1

Views: 1421

Answers (1)

Tim Scott
Tim Scott

Reputation: 15205

I assume that ViewData["DomainID"] is a SelectList? The constructor for SelectList takes a selectedValue object. Use that to pass the selected value in to your select list in the post action.

Upvotes: 2

Related Questions