So, I have a DropdownListfor that looks like this in my opinion:
@Html.DropDownListFor(m => m.ProductCategory, new SelectList(Model.ProductCategories.OrderBy(m => m.PCNumber), "", "Name"), "")
It works as it should. In my next view, the user should be able to edit his order. So, what I want to do if it opens a form, all my data from it should be displayed, for text fields I got its work with the following code:
@Html.TextBoxFor(m => m.NameOfProduct, new { @Value = @Model.NameofProduct })
So now my problem is how can I do the same as with my text fields (giving them the default values from my model) for DropDownListFor when the value is stored in my model (database)? He should like if he chose category 3 earlier and now wants to edit his order earlier, the drop-down list should immediately show category 3.
Thanks for the help!
source
share