How to implement a Gridview in ASP.NET MVC?
There is a built-in WebGrid Helper in ASP.NET MVC that helps to create this. This WebGrid helper was introduced in MVC 3. Using a simple command, @grid.getHtml() can be used to return a populated table with sorting, paging, and GridView lines with alternate lines. The following is a code example that shows how a WebGrid reads data from a database:
var db = Database.Open("StockExchange") ;
var selectQueryString = "SELECT * FROM Nifty ORDER BY Id";
var data = db.Query(selectQueryString);
var grid = new WebGrid(data);
Further, on the HTML page, the following may be used:
<div id="grid"> @grid.GetHtml() </div>
MVC Unit Test Case
CSRF Attacks in MVC
View for MVC Models
Creating MVC Project
Validation helpers in MVC
MVC a Framework or a Design Pattern?
Advantages of MVC Framework
Popular MVC Frameworks
Validation helpers in ASP.NET MVC
Unsable controls in MVC
More Interview Questions...