显示效果:

c# GridView Footor列求合计-LMLPHP

前台代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="../../Css/default.css" rel="stylesheet" type="text/css" />
<script src="../../../Common/Scripts/Order/popup.js" type="text/javascript"></script>
<script src="../../../Common/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div class="default_title_all" style="width: 98%">
<ul>
<li class='hovertab '><span style="color: White">供应商综合分析</span></li>
</ul>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
</Scripts>
</asp:ScriptManager>
<uc4:SupplyAnalysis ID="SupplyAnalysis1" runat="server" />
<div class="default_title_all" style="width: 98%">
<ul>
</ul>
</div>
<table width="98%" border="" align="center" cellpadding="" cellspacing="">
<tr>
<td align="center" valign="top">
<table width="100%" border="" cellspacing="" cellpadding="">
<tr>
<td>
<table width="100%" border="" cellspacing="" cellpadding="" class="margin_center default_table_nobottom_dingdan">
<tr valign="middle">
<td align="right">
区域:
</td>
<td align="left">
<uc3:DropDownListUC ID="ddlArea" runat="server" CssClass="w120" />
</td>
<td align="right">
客户经理:
</td>
<td align="left">
<uc3:DropDownListUC ID="ddlClientManager" runat="server" CssClass="w120" />
</td>
<td align="right">
政策类型:
</td>
<td align="left">
<asp:DropDownList runat="server" ID="ddlType">
<asp:ListItem Text="全部" Value=""></asp:ListItem>
<asp:ListItem Text="普通" Value=""></asp:ListItem>
<asp:ListItem Text="特价" Value=""></asp:ListItem>
<asp:ListItem Text="直减" Value=""></asp:ListItem>
</asp:DropDownList>
</td>
<td align="right">
日期:
</td>
<td align="left">
<input type="text" id="txtBeginTime" runat="server" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"
readonly="readonly" />
至<input type="text" id="txtEndTime" runat="server" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
</td>
<td>
</td>
</tr>
<tr valign="middle">
<td align="right">
航司:
</td>
<td align="left">
<uc3:DropDownListUC ID="ddlAirwayCompanyCode" runat="server" CssClass="w120" />
</td>
<td align="right">
出发:
</td>
<td align="left">
<uc3:TextBoxUC ID="txtDeparturePort" runat="server" CssClass="w120" />
</td>
<td align="right">
到达:
</td>
<td align="left">
<uc3:TextBoxUC ID="txtArrivePort" runat="server" CssClass="w120" />
</td>
<td>
</td>
<td align="left">
<asp:Button ID="btnSearch" runat="server" Text="查 询" CssClass="button_1" OnClick="btnSelect_Click" />&nbsp;&nbsp;
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="" cellspacing="" cellpadding="">
<tr>
<td rowspan="">
<asp:GridView ID="gvInterfaceUser" runat="server" Width="100%" AutoGenerateColumns="False"
GridLines="None" CellPadding="" ShowHeaderWhenEmpty="true" OnRowDataBound="gvInterfaceUser_RowDataBound"
CssClass="default_table margin_center dingdan_table margin_top_10" OnRowCommand="gvInterfaceUser_RowCommand" ShowFooter="True">
<RowStyle HorizontalAlign="Center" CssClass="MsOverBgColor"></RowStyle>
<HeaderStyle HorizontalAlign="Center" Height="28px" CssClass="background_efeff0">
</HeaderStyle>
<FooterStyle HorizontalAlign="Center" Height="28px" CssClass="background_efeff0"
ForeColor="Red" />
<Columns>
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<%#Container.DataItemIndex+ %>
</ItemTemplate>
<ItemStyle Width="4%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:TemplateField>
<asp:BoundField DataField="suUserName" HeaderText="供应商">
<ItemStyle Width="8%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:BoundField> <asp:BoundField DataField="sumCount" HeaderText="总票量">
<ItemStyle Width="8%" CssClass=" default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
<asp:BoundField DataField="pastePoint" HeaderText="贴点票量">
<ItemStyle Width="8%" CssClass=" default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
<asp:BoundField DataField="feesReceivable" HeaderText="手续费应收" DataFormatString="{0:0.00}">
<ItemStyle Width="8%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
<asp:BoundField DataField="pasteTotalMoney" HeaderText="贴点金额" DataFormatString="{0:0.00}">
<ItemStyle Width="8%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
<asp:TemplateField HeaderText="实际收入">
<ItemTemplate>
<%# (Convert.ToDecimal(Eval("feesReceivable")) - Convert.ToDecimal(Eval("pasteTotalMoney"))).ToString("0.00")%>
</ItemTemplate>
<ItemStyle Width="10%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:TemplateField>
<asp:BoundField DataField="DepartCityCount" HeaderText="本地出发票量">
<ItemStyle Width="8%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
<asp:BoundField DataField="ArriveCityCount" HeaderText="回本地票量">
<ItemStyle Width="8%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
<asp:TemplateField HeaderText="异地票量">
<ItemTemplate>
<%# Convert.ToInt32(Eval("sumCount")) - Convert.ToInt32(Eval("DepartCityCount"))-Convert.ToInt32(Eval("ArriveCityCount")) %>
</ItemTemplate>
<ItemStyle Width="10%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:TemplateField>
<asp:BoundField DataField="specailCount" HeaderText="特价票量">
<ItemStyle Width="8%" CssClass="default_table_zc_left default_table_zc_bottom" />
</asp:BoundField>
</Columns>
<AlternatingRowStyle CssClass="F0F0F0 MsOverBgColor" Height="28px" />
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div id="sumCount" runat="server" style="padding-left: 20px; padding-top: 10px;display:none;">
<label>
合计</label>总票量:&nbsp;&nbsp;&nbsp;贴点票量:<asp:Label runat="server" ID="lblsumPasteTicketCount"></asp:Label>&nbsp;&nbsp;&nbsp;手续费应收:<asp:Label
runat="server" ID="lblRecived"></asp:Label>
&nbsp;&nbsp;&nbsp;贴点金额:<asp:Label runat="server" ID="lblPasteMoney"></asp:Label>&nbsp;&nbsp;&nbsp;实际收入:<asp:Label
runat="server" ID="lblActualIncome"></asp:Label>
</div>
</td>
</tr>
<tr>
<td align="center" colspan="">
<uc1:WUCWorkPager ID="WUCWorkPager1" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<div id="details" style="display: none;">
<table>
<tr>
<td>
请求
</td>
<td>
<div id="tdRequest" runat="server">
</div>
</td>
</tr>
<tr>
<td>
返回
</td>
<td>
<div id="tdResponse" runat="server">
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

后台代码:

 public decimal mysum3 = ;//总票量
public decimal mysum4 = ;//贴点票量
public decimal mysum5 = ;//手续费应收
public decimal mysum6 = ;//贴点金额
public decimal mysum7 = ;//本地出发票量
public decimal mysum8 = ;//回本地票量
public decimal mysum9 = ;//特价票量 protected void gvInterfaceUser_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView myrows = (DataRowView)e.Row.DataItem; mysum3 += Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString());
mysum4 += Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString());
mysum5 += Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString());
mysum6 += Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString());
mysum7+= Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString());
mysum8 += Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString());
mysum9 += Convert.ToDecimal(myrows[].ToString() == "" ? "" : myrows[].ToString()); }
// 合计
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[].Text = "合计";
e.Row.Cells[].Text = mysum3.ToString();
e.Row.Cells[].Text = mysum4.ToString();
e.Row.Cells[].Text = mysum5.ToString("0.00");
e.Row.Cells[].Text = mysum6.ToString("0.00");
// 实际收入
e.Row.Cells[].Text = (mysum5 - mysum6).ToString("0.00");
e.Row.Cells[].Text = mysum7.ToString();
e.Row.Cells[].Text = mysum8.ToString();
// 异地票量
e.Row.Cells[].Text = (mysum3-mysum7-mysum8).ToString();
e.Row.Cells[].Text = mysum9.ToString(); }
}
05-07 12:26