首页 新闻 会员 周边

mvc初学者 控制器返回的问题 路过的大侠过来看看吧?

0
悬赏园豆:20 [已解决问题] 解决于 2012-07-16 15:10

控制器:

  public ActionResult Index()
        {
            DataTable dt = CustomerInfo.GetList().Tables[0];
            List<DbCon_view> list = CustomerInfo.GetModel() as List<DbCon_view>;
            if (list.Count > 0)
            {
                return View(list+dt);
            }        }


默认的是希望用户一进来就显示菜单和一个列表 对应的结果集是 dt:list

如何返回啊这2个一起?

视图:

@model System.Data.DataTable
@using WC_DBConsole.Models

@{
    ViewBag.Title = "Index";
}
 <link href="@Url.Content("~/Content/LeftCss.css")" rel="stylesheet" type="text/css" />

<div id="LeftMenu" class="LeftMenu">
    <ul>
        @foreach (System.Data.DataRow item in Model.Rows)
        {
            <li><a id="MeauID" href="#">@item["Customer_Name"]</a></li>
        }
    </ul>
</div>

这个 List<DbCon_view> list = CustomerInfo.GetModel() as List<DbCon_view>;命名空间怎么导入啊 要不会提示

“/”应用程序中的服务器错误。
传入字典的模型项的类型为“System.Collections.Generic.List`1[WC_DBConsole.Models.DbCon_view]”,但此字典需要类型“System.Data.DataTable”的模型项。 

急 等大侠 原谅我提出的低级问题.

s_p的主页 s_p | 初学一级 | 园豆:138
提问于:2012-07-16 12:04
< >
分享
最佳答案
0

@using System.Data

加上这个应该就好了

收获园豆:8
today4king | 老鸟四级 |园豆:3499 | 2012-07-16 13:26

大哥看仔细点@model System.Data.DataTable @using WC_DBConsole.Models我这里已经加载了!

s_p | 园豆:138 (初学一级) | 2012-07-16 13:35
其他回答(1)
0

@model System.Data.DataTable

是错误的。

你的model 本来 就不是 datatable,应该是一个自定义类吧。而 datatable是包含在 这个类中吧。

收获园豆:12
無限遐想 | 园豆:3740 (老鸟四级) | 2012-07-16 15:08

恩 我解决了 返回多个集合 我定义个类 谢了

支持(0) 反对(0) s_p | 园豆:138 (初学一级) | 2012-07-16 15:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册