The below code throws error in IEnumerable conversion issues. Please guide me if I am mising some conversion from controller to view.
controller Code
public ActionResult Index()
{
DataClasses1DataContext db = new DataClasses1DataContext();
var kk = (from x in db.tblTests select x).ToList();
return View(kk);
}
View Code
@model MvcApplication4.Models.sampleDoamin
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
@{
var grid = new WebGrid(Model, defaultSort:"name");
}
@grid.GetHtml()
Model Code
public class sampleDoamin
{
public int id { get; set; }
public string name { get; set; }
}
You declared the view as taking a
sampleDomain, but you passed it anList<T>of some unknown type.That won’t work.