熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

DataGrid腳眉顯示合計

2022-06-13   來源: .NET編程 

  創建一個全局變量

  Public double Sumdb;
    private void DataGrid_ItemCreated(object sender SystemWebUIWebControlsDataGridItemEventArgs e)

  {
          ListItemType lit=eItemItemType;

  if(lit==ListItemTypeFooter)

  {

  TableCell tc=eItemCells[];

  TableCell tc=eItemCells[];

  TableCell tc=eItemCells[];

  TableCell tc=eItemCells[];

  Label L_xj=new Label();

  L_xjID=\lb_xj\;

  L_xjWidth=;

  L_xjText=\合計\;

  tcControlsAdd(L_xj);

  Label L_SumData=new Label();

  L_SumDataID=\L_SumData\;

  L_SumDataWidth=;

  L_SumDataText=SumData();

  tcControlsAdd(L_SumData);

  Label L_zj=new Label();

  L_zjID=\lb_zj\;

  L_zjWidth=;

  L_zjText=\總合計\;

  tcControlsAdd(L_zj);

  Label L_SumPage = new Label();

  L_SumPageID=l_sumPage;

  L_SumPageWidth=;

  L_SumPageText = SumdbToString();

  tcControlsAdd(L_SumPage);

  }

  }
    private void DataGrid_ItemDataBound(object sender SystemWebUIWebControlsDataGridItemEventArgs e)

  {

  if(eItemItemType==ListItemTypeAlternatingItem || eItemItemType==ListItemTypeItem)

  {

  if( ConvertToString( ((DataRowView)eItemDataItem)[\M_sum\]) != stringEmpty)

  {

  dataSum += ConvertToDouble(((DataRowView)eItemDataItem)[\M_sum\]);

  }

  }

  }

  //M_sum為合計的字段名綁定在DataGrid 的!


From:http://tw.wingwit.com/Article/program/net/201311/12824.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.