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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -