为了在 gridview 的页脚行中显示字段的总和,我想从我的动态列表中获取总和,InTopSuppliersView() 位于单独的程序集 DAL 中,而 gridview 位于表示层内。
DAL 中的代码:
public static dynamic InTopSuppliersView()
{
var _pd = from pd in InTopSuppliers()
join pm in PdnmasterDALC.InTopSuppliers() on pd.Pdnmasterid equals pm.Pdnmasterid
select new
{
RefNo = pm.PDNRefNo,
Date = pm.Date
Quantity = pd.QuantityApprovedUOM,
Rate = pd.Rate,
Amount = pd.Amount
};
return _pd;
}
表格代码:
var tmp = InTopSuppliersView();
gvPDNDetail.DataSource = tmp;
gvPDNDetail.DataBind();
gvPDNDetail.FooterRow.Cells[3].Text = tmp.SUM(o => o.Quantity).ToString();
我想获得在查询中动态创建的字段数量和金额的总和