• c# GridView Footor列求合计


    显示效果:

    前台代码:

    <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=" 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=" 98%">
            <ul>
            </ul>
        </div>
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td align="center" valign="top">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0" 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="0"></asp:ListItem>
                                                <asp:ListItem Text="普通" Value="1"></asp:ListItem>
                                                <asp:ListItem Text="特价" Value="2"></asp:ListItem>
                                                <asp:ListItem Text="直减" Value="3"></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="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td rowspan="2">
                                            <asp:GridView ID="gvInterfaceUser" runat="server" Width="100%" AutoGenerateColumns="False"
                                                GridLines="None" CellPadding="0" 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+1 %>
                                                        </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="10">
                                <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>
    View Code

    后台代码:

     public decimal mysum3 = 0;//总票量
            public decimal mysum4 = 0;//贴点票量
            public decimal mysum5 = 0;//手续费应收
            public decimal mysum6 = 0;//贴点金额
            public decimal mysum7 = 0;//本地出发票量
            public decimal mysum8 = 0;//回本地票量
            public decimal mysum9 = 0;//特价票量
    
            protected void gvInterfaceUser_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    DataRowView myrows = (DataRowView)e.Row.DataItem;
                    
                    mysum3 += Convert.ToDecimal(myrows[2].ToString() == "" ? "0" : myrows[2].ToString());
                    mysum4 += Convert.ToDecimal(myrows[3].ToString() == "" ? "0" : myrows[3].ToString());
                    mysum5 += Convert.ToDecimal(myrows[4].ToString() == "" ? "0" : myrows[4].ToString());
                    mysum6 += Convert.ToDecimal(myrows[5].ToString() == "" ? "0" : myrows[5].ToString());
                    mysum7+= Convert.ToDecimal(myrows[6].ToString() == "" ? "0" : myrows[6].ToString());
                    mysum8 += Convert.ToDecimal(myrows[7].ToString() == "" ? "0" : myrows[7].ToString());
                    mysum9 += Convert.ToDecimal(myrows[8].ToString() == "" ? "0" : myrows[8].ToString());
                   
                }
                // 合计
                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    e.Row.Cells[0].Text = "合计";
                    e.Row.Cells[2].Text = mysum3.ToString();
                    e.Row.Cells[3].Text = mysum4.ToString();
                    e.Row.Cells[4].Text = mysum5.ToString("0.00");
                    e.Row.Cells[5].Text = mysum6.ToString("0.00");
                    // 实际收入
                    e.Row.Cells[6].Text = (mysum5 - mysum6).ToString("0.00");
                    e.Row.Cells[7].Text = mysum7.ToString();
                    e.Row.Cells[8].Text = mysum8.ToString();
                    // 异地票量
                    e.Row.Cells[9].Text = (mysum3-mysum7-mysum8).ToString();
                    e.Row.Cells[10].Text = mysum9.ToString();
    
                }
            }
    View Code
  • 相关阅读:
    JS命名空间的使用
    PHPexcel的用法
    python爬取百度贴吧帖子
    python自动抢票
    int 与 String 与 char 之间的互相转换
    数据库备份和恢复
    Mysql 基础
    Mysql错误:Every derived table must have its own alias
    frameset框架集
    文件的上传(TCP)
  • 原文地址:https://www.cnblogs.com/honghong75042/p/3459556.html
Copyright © 2020-2023  润新知