如何在gridview的页脚中计算总价? [英] how to calculate total price in the footer of gridview?
本文介绍了如何在gridview的页脚中计算总价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在gridview的页脚中有此方法
I have this method in the footer of gridview
<asp:TemplateField HeaderText="SALARY">
<ItemTemplate>
<asp:Label ID="sal1" runat="server" Text='<%# Eval("Total") %>'></asp:Label>
</ItemTemplate>
<%-- <asp:BoundField DataField="Total" HeaderText="totalprice" />
--%> <FooterTemplate>
<%# gettotal()%>
</FooterTemplate>
</asp:TemplateField>
现在在此方法中,我想计算总计如何从gridview的total列中的所有单元格中获取值?
now inside this method I want to calculate the total how to get the values from all cells which in the total column in gridview ??
public int gettotal()
{
int totalsal = ;
return totalsal;
}
推荐答案
看看这些:
在GridView的页脚中显示总计 [ MSDN:ASP.NET 2.0的GridView示例:在页脚中显示摘要数据 [ ^ ]
CodeSnip:如何在GridView控件的页脚中显示总数 target ="_ blank" title ="New Window"> ^ ]
如果需要,请查看 ^ ].
Have a look at these:
Displaying Total in Footer of GridView[^]
MSDN: GridView Examples for ASP.NET 2.0: Displaying Summary Data in the Footer[^]
CodeSnip: How to Display Sum Total in the Footer of the GridView Control[^]
If needed, look here[^] for more.
这里是示例总计的页脚............
Here is Example to total in footer............
protected void grdGuestTotal_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType.Equals(DataControlRowType.Footer))
{
//String NetSubTotal = string.Empty;
// String SubTotal = string.Empty;
Label NetSubTotal = ((Label)e.Row.FindControl("lblNetSubTotal"));
Label FinalTotal = ((Label)e.Row.FindControl("lblTotal"));
NetSubTotal.Text = Total.ToString();
FinalTotal.Text = EndTotal.ToString();// (Convert.ToDouble(NetSubTotal.Text) + Convert.ToDouble(SubTotal.Text)).ToString();
}
if (e.Row.RowType.Equals(DataControlRowType.DataRow))
{
//String NetSubTotal = string.Empty;
// String SubTotal = string.Empty;
Label SubTotal = ((Label)e.Row.FindControl("lblSubTotal"));
Label NetTotal = ((Label)e.Row.FindControl("lblNetTotal"));
double value = Convert.ToDouble(SubTotal.Text);
Total += value;
double amount = Convert.ToDouble(NetTotal.Text);
EndTotal += amount;
}
}
已添加CODE标签-LOSMAC [/EDIT]
CODE tags added - LOSMAC[/EDIT]
这篇关于如何在gridview的页脚中计算总价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文