c# - Data of Partial page is not binding in viewModel -


viewmodel:

public class adminaddmoviedatabase     {         public movieinformation movieinformation { get; set; }         public list<genre> genres { get; set; }   } 

basepage:

<div class="contentwrapper1">   <div class="contentleft1">title</div>   <div>   @html.textboxfor(model => model.movieinformation.movietitle, new { @class = "signupinputnamefield", id = "movietitle" }) </div>   </div>   <div id="genre">   <div class="contentleft1">genre</div>   @html.partial("_genrepartialpage", model.genres)   </div> 

partial page:

<div class="contentwrapper1">    <ul><li>      @html.dropdownlist("genrelist", new selectlist(model, "genreid", "genrename"), "--select genre--", new { @class = "contentrightoption1" })     <a href="#" onclick="$(this).parent().remove();">delete</a>       </li></ul>   </div> 

when click on save button of form of base page(which have not given here in sample code). can data of movieinformation model not of data of genres in partial page. couldnot bind viewmodel using partial page. thank you.

your genre list on view model should list<selectlistitem> , should include string property in model. example sake call mygenre. can use

@html.dropdownlistfor(model=>model.genre.mygenre, model=>model.genre.genrelist)

so first property model string, second list of selectlistitem. when form posts can selected item string.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -