MVC LINQ to SQL Table Join Record Display

前端 未结 3 1789
攒了一身酷
攒了一身酷 2020-12-16 09:08

Im having problems displaying records to my view when passing viewdata to a user control. This is only apparent for linq to sql objects where I am using table joins.

3条回答
  •  情歌与酒
    2020-12-16 09:21

    foreach (table1 m in (IEnumerable)ViewData.Model)
    

    m is not of type table1. It is an anonymous type (select new { ... } in CViewDataUC.cs).

    You should create a class that represents the type of the model objects you are passing from controller to view.

提交回复
热议问题