你可以直接访问库,用sql语句求和再写进datagrid里面。

解决方案 »

  1.   

    VB参考:
    C#:
    string count;
    string ConnectionString;
    string strSql = "select count(*) from Editor_Work where Editor_ID="+strEid+" ";
    using(SqlConnection myConnection = new SqlConnection(ConnectionString))
    {
    if(myConnection.State!=ConnectionState.Open)
    myConnection.Open(); SqlCommand myCommand = new SqlCommand();
    myCommand.CommandText=strSql;
    myCommand.Connection=myConnection;
    myCommand.CommandType=CommandType.Text;
    object val=myCommand.ExecuteScalar();
    count=val.ToString();
    }
      

  2.   

    只能用sql了,如果是按页汇总,还能通过在DATAGRID_ITEMDATABOUND事件中写来做
      

  3.   

    好象此段统计某列所有页的总值的C#代码:
    VB代码该如何写
    先统计DataTable中的Column的值,然后再显示再Footer里面:
    int iCount = 0;
    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    {
     iCount += int.Parse(ds.Tables[0].Rows[i]["num"].RoString());
    }
    foreach (DataGridItem item in DataGrid1.Controls[0].Controls)
    {
      if (item.ItemType == ListItemType.Footer)
      {
        item.Cells[0].Text = iCount.ToString();
        return;
      }
    }
      

  4.   

    值已取出,,,该如何写到最后一页的FOOTER去???/
      

  5.   

    1,showfooter=true
    2,ItemDataBound
    if(e.Item.ItemType==ListItemType.Footer)
    {
               e.Item.Cell[列].Text=值;
    }
      

  6.   

    to ppp80:
    如何击活:ItemDataBound呢?
      

  7.   

    点中DATAGRID,在属性框点那个闪电符号,就可以看见DATAGRID的事件了,双击,写代码即可
      

  8.   

    to:rabbitwy(流浪小兔)
    做到了:
    好像是:当程序一开始运行的时候就执行了OnItemDataBound事件吧!
    有点像page_load(),但比它还要早,是吗?