Gridview中LinkedId在DataTable中的行总和

时间:2013-07-25 02:08:07

标签: c# asp.net gridview datatable dataset

我有一个DataTable,其中包含用户可以执行的事务。如何通过LinkedId显示EstimatedTransTime的总和,并在汇总后显示该LinkedTickedId的最大事务?

enter image description here

DataSet ds = new DataSet();
da.Fill(ds);

DataTable dt = new DataTable();
dt = ds.Tables[0];

DataTable newDataTable
    = dt.AsEnumerable()
        .Where(r => !ListLinkedIds.Contains(r.Field<int>("LinkedTicketId")))
        .CopyToDataTable();

gvMain.DataSource = newDataTable;
gvMain.DataBind();

1 个答案:

答案 0 :(得分:0)

我认为你的查询应该是这样的

SELECT TicketID,DisplayNum,TranstypeDesc,    SubQueueId,SUM(EstimatedTransTime),LinkedTicketId FROM vwQueueData WHERE    (DATEADD(day,DATEDIFF(day,0,Issued),0)= DATEADD(day,DATEDIFF(day,0,    GETDATE()),0))AND QId = @QId AND SubId = @SubId AND Called IS NULL   group by LinkedTicketId

尝试这个并告诉我是否有任何错误