C# と SQL Server 2005 を使用して ASP .Net MVC 3 アプリケーションを開発しています。
Entity Framework と Code First Method も使用しています。
このモデルのリストを使用しているため、モデル ビュー '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; }
}
そしてこれがゲームモデルです:
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();
}
}