Quote:Good morning all, I'm crashing in front of this error message (Error: CS0246: Type or namespace name 'ModelReturn' could not be found (are you missing a using directive or assembly reference *?)): Let me explain : - Basically in my view I have this declaration at the top of my page (@Model Client) AND in the Controller return View (GestionClients); .... It works. - In another creation in my view I have this declaration at the top of my page (@model IEnumerable <product>) AND in the Controller return View (db.Tbl_produits.ToList ()); .... It works. Having said that, now I want to bring the two @Models together in one view. So I declare a class that I name (MultiModels), here is:
using System.Collections.Generic; namespace Site_LsB_MVC.Models { public class MultiModels { public IEnumerable<Produit> Produits { get; set; } public Client Clients { get; set; } } }
Quote:Dans mon Controller j'ai ce qui suit :
public class ProdDbContext : Controller { private Data.ProdDbContext db = new Data.ProdDbContext(); public static Client cMain; public ActionResult Index() { Client GestionClients = new Client(); cMain = new Client(); GestionClients.Clients = cMain.Clients = FillList(); MultiModels RetourModel = new MultiModels {Produits = db.Tbl_produits.ToList(), Clients = GestionClients}; return View(RetourModel); } }
Et dans ma vue je note : @model RetourModel Aucun soucis sur les déclarations de mes inputs et les @Html.TextAreaFor, n'y sur le @foreach (var item in Model.Produits). Par contre dans ma liste d'erreurs j'ai deux codes CS0246 comme indiqué en haut de mon message ! Me manque t'il une déclaration quelconque ? Merci d'avance pour votre aide.
@model MultiModels
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)