我正在使用MVC 3 webgrid,我需要向webgrid添加一行以顯示產品表中的價格總和。
任何想法表示讚賞。
這裏是我的代碼
在webgrid中添加行
@{
WebGrid grid = new WebGrid(source: Model,
rowsPerPage: 3,
canSort: true,
canPage: true,
ajaxUpdateContainerId: "ajaxgrid");
@grid.GetHtml(
alternatingRowStyle: "altrow",
mode: WebGridPagerModes.All,
firstText: "<< ",
previousText: "< ",
nextText: " >",
lastText: " >>",
columns: grid.Columns(
grid.Column(format: (item) => new HtmlString(Html.ActionLink("Edit", "Edit", new { id = item.ProductId }).ToString() + " | " +
Html.ActionLink("Delete", "Delete", new { id = item.ProductId }).ToString()
)
),
grid.Column("ProductId", "Product Id"),
grid.Column("CategoryId", "Category Name", format: (item) => item.Category.CategoryName),
grid.Column("ProductName", "Product Name"),
grid.Column("Price", "Price", format: @<text>@String.Format("{0:c}", item.Price)</text>)
)
)
}