DataGrid中有ID,Name,Quantity三列,我想在DataGrid最后一行显示Quantity列的合计数,怎么实现?

解决方案 »

  1.   

    得在DataGrid的数据源DataTable中加入一行。
    或者直接将Quantity列的合计数放在DataGrid的CaptionText属性中,如:
    dataGrid1.CaptionText = "总数量:"+((double)DataTable.Tables["ddlb"].Compute("SUM([Quantity])",null)).ToString("N");
      

  2.   

    private void projectinfo_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {

    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
    { e.Item.Cells[4].Text =  Convert.ToUInt16(e.Item.Cells[0].Text)+ Convert.ToUInt16(e.Item.Cells[1].Text)+ Convert.ToUInt16(e.Item.Cells[2].Text);


    }
    }
      

  3.   

    DataGrid中有ID,Name,Quantity三列,我想在DataGrid最后一行显示Quantity列的合计数,怎么实现?
    是行的合计吗???
    列是3
      

  4.   

    HOW TO: Create a Summary Row for a DataGrid in ASP.NET  http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q313154