我看见教程通过return View(model);的方式 , 把model从控制器传到了视图,感觉要点就是model是强类型就可以了, 于是我也试了一把, 以下代码是 控制器的代码
public ActionResult GetString()
{
Maticsoft.BLL.Asend bll = new Maticsoft.BLL.Asend();
List<Maticsoft.Model.Asend> model = bll.GetModelList("addresser='徐海云'");
return View(model);
}
其中GetModelList 方法如下
public List<Maticsoft.Model.Asend> DataTableToList(DataTable dt)
{
List<Maticsoft.Model.Asend> modelList = new List<Maticsoft.Model.Asend>();
int rowsCount = dt.Rows.Count;
if (rowsCount > 0)
{
Maticsoft.Model.Asend model;
for (int n = 0; n < rowsCount; n++)
{
model = dal.DataRowToModel(dt.Rows[n]);
if (model != null)
{
modelList.Add(model);
}
}
}
return modelList;
}
我在视图中.@model. 怎么也带出来强类型出来, 请大家指点我一下,我错在那里,该如何纠正.
------解决思路----------------------
[email protected]?
------解决思路----------------------
