zoukankan      html  css  js  c++  java
  • GridView显示总合计

     <asp:GridView ID="GridView1" runat="server" Width="100%" DataKeyNames="ID" AutoGenerateColumns="False"  OnRowDataBound="GridViewIw1_RowDataBound" >
        
    <Columns>
    。。。。。。。。。。。。。。。
     
    <asp:BoundField DataField="SumPrice" HeaderText="金额"  SortExpression="SumPrice" DataFormatString="{0:C}" HtmlEncode="False"  >
                                  
    <itemstyle width="8%" />

                                  
    </asp:BoundField>
    。。。。。。。。。。。。。。。。。
    </Columns>
    </asp:GridView >

    格式化的时候一定要把HtmlEncode设为"False"
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            
            DataControlRowType lit = e.Row.RowType;
            if (lit == DataControlRowType.Footer)
            {           
                TableCell tcprice = e.Row.Cells[3];            
                TableCell price = e.Row.Cells[4];
                            tcprice.Text = "总金额:";
                           tcprice.HorizontalAlign = HorizontalAlign.Right;
                        price.Text = "¥"+GetPrice();
                               
            }
               }

    private string  GetPrice()
    {
    return "3459";
    }

    在脚里就能显示总合计了!
  • 相关阅读:
    《数据库系统概论》第三章笔记
    《数据库系统概论》第二章笔记
    《数据库系统概论》第一章笔记
    《Java并发编程的艺术》第九章笔记
    Dijkstra算法
    LaTex插图总结
    PDF中点击参考文献如何回到正文
    清华大学SCI论文写作心得
    LaTex写论文
    MATLAB中ode23函数,龙格库塔函数
  • 原文地址:https://www.cnblogs.com/anson/p/457113.html
Copyright © 2011-2022 走看看