HOW TO USE WEBGRID IN MVC

Ankit Singh

Total Post:341

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

  1. aditya kumar Patel

    Post:254

    Points:1810
    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 Dec-25-2015 09:46:24 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!