How to use WebGrid in mvc

Total Post:341

Points:2389
C#  .NET  Mvc  Mvc3  Mvc2  Mvc4  Mvc5 
 972  View(s)
Ratings:
Rate this:
I want to use WebGrid in mvc how to do this please help me.

  1. Post:281

    Points:2003
    Re: How to use WebGrid in mvc

    WebGrid is most powerful tools to list records from database in web application. Like ASP.NET Web Forms GridView, DataList, ASP.NET MVC didn't had any built in data controls. WebGrid that does almost all work of ASP.NET Web Form GridView and it is simple enough too.

    Index.cshtml

    @model IList<ForumMVC.Employee>

    @{
        ViewBag.Title = "Index";
    }
     @{ 
    var grid = new WebGrid(Model);
    }

    <h1>Employee List </h1>
    <div id="grid">
    @grid.GetHtml()
    </div>

     

    HomeController

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using ForumMVC;
    using System.Data.Entity;
    namespace ForumMVC.Controllers
    {
        public class HomeController : Controller
        {
            forumEntities db = new forumEntities();
            public ActionResult Index()
            {
                List<Employee> Emplst = db.Employee.ToList();
                return View(Emplst);
            }
        }
    }

      Modified On Apr-10-2018 06:47:48 AM

Answer