• 对DataTable进行求和、平均等数学运算


      private void dgMain_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
       ListItemType itemtype=e.Item.ItemType;
       if(itemtype==ListItemType.Footer)
       {
        DataTable tbTotal=(DataTable)(dgMain.DataSource);
        //e.Item.Cells[0].ColumnSpan=2;
        e.Item.Cells[1].Visible=false;
        e.Item.Cells[0].Text="<B>合  计</B>";
        if(tbTotal.Rows.Count>0)
        {
         e.Item.Cells[2].Text=tbTotal.Compute("sum([留言总数])","1>0").ToString();
         e.Item.Cells[3].Text=tbTotal.Compute("sum([公开留言])","1>0").ToString();
         e.Item.Cells[4].Text=tbTotal.Compute("sum([个别留言])","1>0").ToString();
         e.Item.Cells[6].Text=tbTotal.Compute("sum([家长留言])","1>0").ToString();
        }
        else
        {
         e.Item.Cells[2].Text="0";
         e.Item.Cells[3].Text="0";
         e.Item.Cells[4].Text="0";
         e.Item.Cells[6].Text="0";
        }
        e.Item.Cells[5].Text="";
       }
       if(itemtype==ListItemType.Item || itemtype==ListItemType.AlternatingItem)
       {
        e.Item.Cells[1].Text = WebComponents.s2pDataTranslate.GetSchoolTypeNameState(e.Item.Cells[7].Text.ToString()) + "-" + e.Item.Cells[1].Text;
       }
      }

    <ASP:DATAGRID ID="dgMain" RUNAT="server" AUTOGENERATECOLUMNS="False" CSSCLASS="FixTable" WIDTH="545"
        SHOWFOOTER="True">
  • 相关阅读:
    KVM安装配置
    cobbler配置解析
    denyhosts配置详解
    Rsync+sersync实现数据实时同步
    Linux启动提示Kernel panic
    oracle常用的数据字典
    Cachefiled
    from __future__ import division
    Java Map用法
    CCF系列之窗口(201403-2)
  • 原文地址:https://www.cnblogs.com/JimZhang/p/318164.html
Copyright © 2020-2023  润新知