以下代码在 IEnumerable 转换问题中引发错误。如果我错过了从控制器到视图的一些转换,请指导我。
控制器代码
public ActionResult Index()
{
DataClasses1DataContext db = new DataClasses1DataContext();
var kk = (from x in db.tblTests select x).ToList();
return View(kk);
}
查看代码
@model MvcApplication4.Models.sampleDoamin
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
@{
var grid = new WebGrid(Model, defaultSort:"name");
}
@grid.GetHtml()
型号代码
public class sampleDoamin
{
public int id { get; set; }
public string name { get; set; }
}