Bonjour,
SVP j'ai un problème d'affichage, quand j'exécute j'obtient l'erreur suivante
{"The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Apoline.Entities.Models.ParamFormat]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Apoline.Web.Models.ParamFormat]'."}
Le nom du projet est Apoline
dans Apoline.Web.Views j'ai :
le fichier index.chtml:
@model IEnumerable<Apoline.Web.Models.ParamFormat>
@using (Html.BeginForm())
{
<p>
Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
<input type="submit" value="Search" /></p>
}
<table>
<tr>
<th></th>
<th>
@Html.ActionLink("Libellé", "Index", new { sortOrder=ViewBag.NameSortParm, currentFilter=ViewBag.CurrentFilter })
</th>
<th>
@Html.ActionLink("Valeur", "Index", new { sortOrder=ViewBag.NameSortParm, currentFilter=ViewBag.CurrentFilter })
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ForID}) |
</td>
<td>
@Html.DisplayFor(modelItem => item.ForLibLong)
</td>
<td>
@Html.DisplayFor(modelItem => item.ForVal)
</td>
</tr>
}
</table>
dans Apoline.BL j'ai le fichier ParamFormatService:
ApolineContext ctxApoline = new ApolineContext();
public List<ParamFormat> GetAllParamFormats()
{
try
{
var formats = ctxApoline.ParamFormat.ToList();
return formats;
}
catch (Exception e)
{
this.LogError("Error getting formats List", e);
return null;
}
}
Dans Apoline.Web.controllers j'ai le fichier ParamFormatController:
public class ParamFormatController : BaseController
{
public ViewResult Index()
{
ParamFormatService srv = new ParamFormatService();
List<ParamFormat> formats = srv.GetAllParamFormats();
return View(formats.ToList());
}
dans Apoline.web.models j'ai le fichier ParamFormat.cs
public class ParamFormat
{
public int ForID { get; set; }
[Column("ForDateCre")]
[Display(Name = "date de création")]
public DateTime ForDateCre { get; set; }
[Column("ForVal")]
[Display(Name = "user de création")]
public string ForVal{ get; set; }
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
[Column("ForDateModif")]
[Display(Name = "date de modification")]
public DateTime ForDateModif { get; set; }
[Column("ForUserModif")]
[Display(Name = "user de modification")]
public string ForUserModif { get; set; }
[Column("ForLibLong")]
[Display(Name = "Libellé")]
public string ForLibLong { get; set; }
en attente de votre aide, je vous remercie énormement.
Partager