bonjour à tous !

Je vous donne de suite l'erreur:
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[CVManager.Models.Grade]' but this dictionary requires a model item of type 'CVManager.Models.ViewData.IndexModel'.
Dans mon controler (Index) j'ai:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public ActionResult Index()
        {
            var model = new IndexModel
            {
                Grades = _service.ListGrade(),
                DiplomaInGrade = _service.ListDiplomaInGrade()
            };
            return View(model);
        }
 
[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index([Bind(Exclude = "Id")]Grade gradeToCreate)
        {
            if (_service.CreateGrade(gradeToCreate))
                return RedirectToAction("Index");
            return View("Index", _service.ListGrade());
        }
Dans ma page Aspx j'ai une liste de mes models Grade en première partie puis une zone de création (simple):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CVManager.Models.ViewData.IndexModel>" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<title>Graduations</title>
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
    <h2>List Graduations</h2>    
    <%= Html.ValidationSummary("Creation was unsuccessful. Please correct the errors and try again.")%>    
    <table class="data-table" cellpadding="0" cellspacing="0">
    <thead>
        <tr>
            <th class="actions">
                Edit                  
            </th>
            <th class="actions">
                Delete
            </th>
            <th>
                Name
            </th>
            <th>
                # Diploma
            </th>
        </tr>
    </thead>
    <tbody>
    <% var diplomaInGrade = new ArrayList();
       foreach (var item in Model.DiplomaInGrade)
       {
           diplomaInGrade.Add(item.Diploma.Count);
 
       }
       int i = 0;
        foreach (var item in Model.Grades) { %>
 
        <tr>
           <td class="actions">
                <a href='<%= Url.Action("Edit", new {id=item.Id}) %>'><img src="../../Content/Edit.png" alt="Edit" /></a>
            </td>
            <td class="actions">
                <a href='<%= Url.Action("Delete", new {id=item.Id}) %>'><img src="../../Content/Delete.png" alt="Delete" /></a>
            </td>            
            <td>
                <%= Html.Encode(item.Name) %>                
            </td>
            <td>
                <%= Html.Encode(diplomaInGrade[i].ToString())%>
            </td>
        </tr>
 
      <%i++;} %>
    <tr>
        <th colspan="5">Add:</th>
    </tr>
 
    <tr><% using (Html.BeginForm("Index", "Grade", FormMethod.Post, new { id = "TheForm" }))
           { %>
 
        <td class="actions" colspan="2">
            <input type="submit" value="Create" />
        </td>        
        <td>    
            <%= Html.TextBox("Name") %>
            <%= Html.ValidationMessage("Name", "*") %>
        </td>
        <td></td>   
        <% } %>
    </tr>
 
    </tbody>
    </table>
</asp:Content>
La création se passe bien seulement j'ai un problème si j'essaye de créer avec un champs vide (pour tester le validator de mon Model).

Personnellement je ne sais pas trop quoi faire, je ne vois même pas pourquoi il me sort un type du genre "CVManager.Models.Grade" alors que j'ai tout passé en "Models.ViewData.IndexModel" ??? :S

Merci beaucoup pour votre compréhension.