如何获取 viewbag 数据,我创建了一个控制器,该控制器从数据库中获取数据并尝试在视图中显示数据,但它不显示数据。
public ActionResult Show()
{
List<Models.Employees> lst = new List<Models.Employees>();
Models.Employees obj = new Models.Employees();
DataSet ds =new Models.BL.InsertBL().GetShow(obj);
lst = (from DataRow drw in ds.Tables[0].Rows
select new Models.Employees
{
Enames = drw["Ename"].ToString(),
DepartId =Convert .ToInt32(drw["Departmentid"]),
EmailIds = drw["Emailid"].ToString(),
Adress = drw["Address"].ToString()
}).ToList();
ViewBag.Sasi = lst;
return View();
}
@{
ViewBag.Title = "Show";
Layout = "~/Views/Shared/VideoLayout.cshtml";
var vv = ViewBag.Sasi;
}