In this chapter you will learn
- What is WebGrid?
- How to display data using WebGrid?
- Programming Example
What is WebGrid?
WebGrid is new technology to display data in tabular format. It is launch with ASP MVC. It is lightweight, easy to use and works well with Razor Syntax. It adds paging automatically.How to declare WebGrid?
You can declare WebGrid as followvar sqldb=Database.Open("Database Tutorial"); var sqlquery="SELECT * FROM Library"; var data=sqldb.Query(sqlquery); var grid=new WebGrid(data);
How to display data using WebGrid?
Programming Example@{ var sqldb=Database.Open("Database Tutorial"); var sqlquery="SELECT * FROM Library"; var data=sqldb.Query(sqlquery); var grid=new WebGrid(data); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> @{ @grid.GetHtml(); } </body> </html>Output
ID | BookName | Author |
---|---|---|
1 2 3 > | ||
1 | C# | Christian Nagel |
2 | ASP.NET MVC | Simone Chiaretta |
3 | Microsoft SQL Server | Paul Turley |
4 | Android Programming | DiMarzio Jerome |
5 | Scala | Janek Bogucki |
6 | .NET Core 1.0 | Christian Nagel |
7 | Visual Studio 2015 | William Penberthy |
8 | Swift IOS | Abhishek Mishra |
9 | Visual Basic 2015 | Bryan Newsome |
10 | Python | Luke Sneeringer |