Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET Web Pages WebGrid

ASP.NET Web Pages - WebGrid Helper


The WebGrid - one of many useful ASP.NET Web helpers.


Hand-written HTML

In previous chapters, you used Razor code to display database data, and all the HTML markup was hand-written:

Database Example

@{
var db = Database.Open("SmallBakery");
var selectQueryString = "SELECT * FROM Product ORDER BY Name";
}

Small Bakery Products

@foreach(var row in db.Query(selectQueryString))
{

}

Id Product Description Price

@row.Id

@row.Name

@row.Description

@row.Price

Run Example »


Using the WebGrid Helper

The WebGrid helper provides a simpler way to display data.

The WebGrid helper:

WebGrid Example

@{
var db = Database.Open("SmallBakery") ;
var selectQueryString = "SELECT * FROM Product ORDER BY Id";
var data = db.Query(selectQueryString);
var grid = new WebGrid(data);
}

Displaying Data Using the WebGrid Helper

Small Bakery Products

@grid.GetHtml()

Run Example »