【发布时间】:2014-05-24 16:46:40
【问题描述】:
问题出在:
双 dItemPremium = (Eval("Premium")!= DBNull.Value) ? (double)(Eval("Premium")) : 0;
我需要帮助来改变它。
我正在使用 Gridview。
protected void dgCustomer_DataBound(object sender, System.EventArgs e)
{
Label pLabel = new Label();
double dItemPremium = (Eval("Premium")!= DBNull.Value) ? (double)(Eval("Premium")) : 0;
pLabel.Text = dItemPremium.ToString("0.00");
dTotal_m += dItemPremium;
dgCustomer.HeaderRow.TableSection = TableRowSection.TableHeader;
dgCustomer.FooterRow.TableSection = TableRowSection.TableFooter;
dgCustomer.FooterRow.Controls.Add(pLabel);
}
protected void dgCustomer_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
dTotal_m += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem,"Premium"));
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Totals:";
e.Row.Cells[1].Text = dTotal_m.ToString("0.00");
e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
e.Row.Font.Bold = true;
}
}
在我使用的 HTML 中
<asp:TemplateField>
<ItemTemplate>
<%#DataBinder.Eval(DataItem,"Premium")%></ItemTemplate>
<HeaderTemplate>
Premium Amount Paid</HeaderTemplate>
</asp:TemplateField>
我添加了 DataBinder 和 DataItem 但仍然没有。
谢谢!
【问题讨论】:
标签: asp.net