asp.net mvc - how to set Enum in DropDownListFor and keep selectet item when back to this page in mvc? -
when use code in firstpage , go other page , , come page passing model first page, selected value in dropdownlist not found
@html.dropdownlistfor(model => model.supplementary.bloodgroup, enumhelper.getselectlist(typeof(azarweb.domain.hrm.providingstaff.core.enumeration.bloodgroupenum)), "please select 1 item", new { @class = "form-control" })
how set selectet value in dropdownlistfor when come page?
there 2 ways, depending on doing.
if calling server controller, , on return want "remember" dropdownlist selected value, you'll need pass view in model.
the best option create dropdownlist control through selectlist object passed in model. 1 of parameters of selectlist constructor selected value.
https://msdn.microsoft.com/es-es/library/system.web.mvc.selectlist(v=vs.118).aspx
the other way around not having remember because don't reload whole page. depending how managing webpage browsing, when send info server can use ajax call. whith page isn't reloaded, selected dropdownlist doesn't lose it's current value after server returns.
Comments
Post a Comment