我使用C#和SQL Server 2005如何在ASP MVC 3
我也使用实体框架和代码的方法首先开发一个ASP.NET的MVC 3应用程序中使用从型动物模型参数应用在同样的观点。
我有一个从模型视图'FlowModelView'继承的部分视图,因为我使用了这个模型中的列表。
我想使用另一个模型'Gamme'的参数。
当我尝试这个,,,声明总是在红色下划线。
这是局部视图:
<%@ 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>
<% } %>
这个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; }
}
,这是的Gamme型号:
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; }
}
and this the controller but contains some 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();
}
}
感谢MIXTE ,,,但是当我改变“的RenderPartial” ,,,昨天的空例外返回 – anouar 2013-05-14 13:33:17
OK我已经回到到该聊天室 – 2013-05-14 13:36:26