我們已經在數組中領先名稱。通過這種方式,我解決了這個問題
#region Grouping by Teamlead
DataTable dtGroup = new DataTable();
dtGroup = dtResult.Clone();
foreach (DataColumn dc in dtResult.Columns)
{
dc.DataType = typeof(string);
}
dtGroup.AcceptChanges();
foreach (string s in srLead)
{
string name = s;
DataTable dtsource = new DataTable();
dtsource = TeamLeadFilter(dtResult, name);
CombineDatatable(ref dtGroup, dtsource);
dtGroup.AcceptChanges();
}
#endregion
#region TeamLeadFilter
public DataTable TeamLeadFilter(DataTable dtResult, string str)
{
DataView dvData = new DataView(dtResult);
dvData.RowFilter = "TeamLead ='" + str + "'";
return dvData.ToTable();
}
#endregion
#region CombineDatatable
public DataTable CombineDatatable(ref DataTable destini, DataTable source)
{
foreach (DataRow dr in source.Rows)
{
destini.ImportRow(dr);
}
return destini;
}
#endregion
:
string[] srLead = { "vinay", "sandeep", "anitha", "rohit" };
然後取源數據表和篩選它基於領先的名字,並添加到一個新的DataTable。
你是什麼意思與格式?格式化到屏幕? – Carra 2010-08-05 07:29:18