asp.net mvc 3 - DropDownFor changes selected value of SelectedList -
i have strange problem dropdownlistfor. need create dynamically selected lists in page, so, i've written code
(int = 0; < this.model.rolepermissions.count(); i++ ) { var item = this.model.permissionslist.first(m => m.text == this.model.rolepermissions.elementat(i).name.tostring()); item.selected = true; <div class="row"> <div class="holder"> <div class="col with-button"> @this.html.dropdownlistfor(m => m.listid, this.model.permissionslist, new { @class = "select2" }) </div> </div> @{ item.selected = false; } </div> }
rolepermissions - ienumerable, values, must selected in selectedlist permissionlist - ienumerable needed values.
so, when page rendered - selection in 1 selected index. wrong?
so... needed
modelstate.clear()
in controller.
Comments
Post a Comment