I have a drop down list that i am looking to retain the selected item after postback to the controller.
In my controller i have -
ViewBag.SectionsID = new SelectList(_sectionRepo.getSections(), "ID", "Name");
Which is used with the following dropdownlist within my razor view -
@Html.DropDownList("SectionsID", (IEnumerable<SelectListItem>)ViewBag.SectionsID, Resources.LblPleaseSelect, htmlAttributes: new { @class = "form-control" })
My controller currently passes a viewmodel back to the view that contains a list of records that are displayed. The mentioned drop down is also in this view as a way to select various Record Sections and then sort the displayed records by section.
Currently when the view is loaded the DDL shows "please select" when a section is selected and the submit button pressed the view returns all records within that section but the ddl shows "please select" and not the selected section...
Any help would be appreciated.
- marked as duplicate...the link you have show is not a duplicate of this question at all. Can you please elaborate?