top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to implement a Gridview in ASP.NET MVC?

+1 vote
350 views
How to implement a Gridview in ASP.NET MVC?
posted Sep 1, 2016 by Jayshree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
  • 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()
answer Sep 6, 2016 by Shivaranjini
...