我的观点是这样的:
@{
var categories = (List<C_Category>)Model.c;
}
@foreach (C_Category cat in categories)
{
<option value="@cat.C_Id">@cat.C_Name</option>
}
这在我的控制器中:
[HttpGet]
public ActionResult Admin()
{
using (var context = new sopingadbEntities())
{
List<P_Product> p = context.P_Product.OrderByDescending(x => x.P_Id).ToList();
List<C_Category> c = context.C_Category.ToList();
var ao = new AdminObj()
{
p = p,
c = c
};
return View("Admin", new { c, p });
}
}
但是在我看来,我会出错:
“ Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:“对象”不包含“ c”的定义”
我确定我一直在这样做,我想念什么吗?