I speak a little English. I am trying to ask my question.
I have a model. this is the name of Product.cs
Product { public int TypeId { get; set; } public string TypeName { get; set; } public int TradeMarkId { get; set; } public string TradeMarkName { get; set; } public int ProductId { get; set; } public string ProductName { get; set; } public int TId { get; set; } public int TMId { get; set; } public List<TypeProduct> typeList { get; set; } }
My controller page
My controller [HttpGet] public ActionResult TradeMarkProduckAdd() { Product product = new Product(); TypeList typeList = new TypeList(); product = typeList.TypeListOf(product); return View(product);
it speaks of an error of the type The model element passed to the dictionary is of type "TypeMark.Models.Product", but this dictionary requires a model element of the type "System.Collections.Generic.IEnumerable`1 [TypeMark.Models.Product]".
when i got this error i changed return View (product); return View ((IEnumerable)) , but it did not work again.
view page
@using TypeTradeMark.Models @model IEnumerable<Product> @using (Html.BeginForm("AddProduct", "Home", FormMethod.Post)) { @foreach(var item in Model as List<Product>) { @item.ProductName @item.??//checkbox for every record @item.??//dropdownlist for trademarks } }
Class typelist
TypeList class public class TypeList { VtDataContext Vt = new VtDataContext(); public Product TypeListOf(Product typeListOf) { var query = (from c in Vt.Types select c); typeListOf.typeList=new List<Type>(query.ToList()); return typeListof; } }
my tables
Type : TypeId, TypeName TradeMark : TradeMarkId,TradeMarkName TProduct : ProductId,ProductName,TId,TMId//TId relation with TypeId, TMId relation with TradeMarkId
I could not solve the problem. Can you help me? thanks