@model IEnumerable<ForumMVC.Employee> @{ ViewBag.Title = "Bind Gridview with Database"; WebGrid grid = new WebGrid(Model); } <h2>Bind GridView in MVC4 with Database</h2> @grid.GetHtml(columns: new[] { grid.Column("Emp_ID"), grid.Column("Emp_Name"), grid.Column("Emp_Sal") } )
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Threading.Tasks; using System.Diagnostics; using ForumMVC; namespace ForumMVC.Controllers { public class HomeController : Controller { forumEntities db = new forumEntities(); public ActionResult Index() { IEnumerable<Employee> LIst = db.Employee.ToList(); return View(LIst); }
} }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Can you answer this question?
Write Answer1 Answers