WebGrid - One of many useful ASP.NET web helpers.
Written HTML
In the previous chapter, you used Razor code to display database data. All HTML tags were handwritten:
Database Example
@{ var db = Database.Open("SmallBakery"); var selectQueryString = "SELECT * FROM Product ORDER BY Name"; }Small Bakery Products
Id | Product | Description | Price |
---|---|---|---|
@row.Id | @row.Name | @row.Description | @row.Price |
Using the WebGrid Helper
The WebGrid Helper provides an easier way to display data.
WebGrid Helper:
Automatically create an HTML table to display data
Support different formatting options
Support data paging display
Support sorting by clicking on the list title
WebGrid instance
@{ 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()
[Related recommendations]
2.Share ASP.NET study notes (8) WebPages Helper
3.Share ASP.NET study notes (7) WebPages object detailed explanation
4.Detailed introduction to ASP.NET MVC--View
5.A brief definition and introduction to ASP.NET
The above is the detailed content of Parse WebGrid - Very useful ASP.NET web helper. For more information, please follow other related articles on the PHP Chinese website!