c# - How to use parametres from differents models in the same View in ASP MVC 3 -


i developing asp .net mvc 3 application using c# , sql server 2005.

i using entity framework , code first method.

i have partial view inherit model view 'flowmodelview' because using list model.

i want use parametres model 'gamme'.

when try this,,,the statement underline in red.

this partial view :

<%@  language="c#" inherits="system.web.mvc.viewusercontrol<mvcapplication2.models.flowviewmodel.gamme>" %>  <% using (html.beginform()) { %>     <%: html.validationsummary(true) %>     <fieldset class="parametrage">         <legend>gestion de gamme</legend>          <div><%:html.label("poste :")%><%: html.dropdownlist("selectedposte", model.postesitems)%></div>            <div><%:html.label("nombre de passage :")%><%: html.editorfor(model.gamme=>model.gamme.nbr_passage) %></div>          </fieldset>          <% } %>  

this flowviewmodel :

public class flowviewmodel     {          [key]         public string idv { get; set; }         [notmapped]         public selectlist postesitems { get; set; }         //public list<poste> postesitems { get; set; }         public list<profile_ga> profile_gaitems { get; set; }         public list<gamme> gaitems { get; set; }          public int selectedprofile_ga { get; set; }          public int selectedgamme{ get; set; }          public int selectedposte { get; set; }     } 

and gamme model :

namespace mvcapplication2.models {     public class gamme     {         [key]         [column(order = 0)]         [foreignkey("profile_ga")]         public string id_gamme { get; set; }         [key]         [column(order = 1)]         [foreignkey("poste")]         public string id_poste { get; set; }         public int position { get; set; }         public int nbr_passage { get; set; }         public string last_posts { get; set; }         public string next_posts { get; set; }          public virtual poste poste { get; set; }         public virtual profile_ga profile_ga { get; set; }      } , controller contains errors :     public class anouarcontroller : controller     {            //         // get: /anouar/           public actionresult gestion()          {             var model = new flowviewmodel()             { yourgammemodel = new gamme(){          public string id_gamme { get; set; }          public string id_poste { get; set; }         public int position { get; set; }         public int nbr_passage { get; set; }         public string last_posts { get; set; }         public string next_posts { get; set; }          public virtual poste poste { get; set; }         public virtual profile_ga profile_ga { get; set; }              }};               return partialview();           }         } 

based on code sent me yesterday, you're rendering gestion partial within view, controller action isn't hit. need change index.aspx says

html.renderpartial("gestion")

to

html.renderaction("gestion", "anouar", model)

and change controller action this:

public actionresult gestion(flowviewmodel model) {     model.yourgammemodel = new gamme();      return partialview(model);  } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -