How to implement a Gridview in ASP.NET MVC?

How to implement a Gridview in ASP.NET MVC?



- ASP.NET MVC provides a WebGrid Helper to create Gridview dynamically which was introduced in MVC3.

-By using only a single command i.e. @grid.getHtml() we can populate the data in Gridview with the functionalities like sorting, paging, alternate rows etc.

-For example:
@{
var db = Database.Open("EmployeeDatabase") ;
var qry = "SELECT * FROM EmpDetails";
var data = db.Query(qry);
var empdata = new WebGrid(data);
}
-On the HTML page we have use following:
@empdata.GetHtml()
Post your comment