i need to have Total of price displayed in webgrid. from the code below.
@{ var db = Database.Open("SmallBakery") ; var selectQueryString = "SELECT * FROM Product ORDER BY Id"; var data = db.Query(selectQueryString); var grid = new WebGrid(source: data, defaultSort: "Name", rowPerPage: 3); } <!DOCTYPE html> <html> <head> <title>Displaying Data Using the WebGrid Helper (Custom Formatting)</title> <style type="text/css"> .product { width: 200px; font-weight:bold;} </style> </head> <body> <h1>Small Bakery Products</h1> <div id="grid"> @grid.GetHtml( columns: grid.Columns( grid.Column("Name", "Product", style: "product"), grid.Column("Description", format:@<i>@item.Description</i>), grid.Column("Price", format:@<text>$@item.Price</text>) ) ) </div> </body> </html>
use LINQ to get what you want