一、排序
DataView dv=dt.DefaultView;dv.Sort="id asc,name desc";
dt=dv.ToTable();
二、檢索
string strName = matches[0]["name"].ToString();
三、合並
假如有2個DataTabel:Dt1,Dt2。表結構一樣將Dt2接在Dt1后可采用方法
Dt1.Merge(Dt2);
四、分頁
PagedDataSource pds = new PagedDataSource();pds.AllowPaging = true ;
pds.DataSource = dvIntegralExpense;
pds.AllowPaging = true ;
pds.PageSize = pager.PageSize;
pds.CurrentPageIndex = pager.PageIndex;
rptIntegralExpense.DataSource = pds;
rptIntegralExpense.DataBind();
五、統計
DataTable實現統計,調用Compute函數,函數原型:
public object Compute(string strExpression,string strFilter)
參數:
strExpression:要計算的表達式字符串,基本上類型於Sql Server中的統計表達式
strFilter:統計的過濾字符串,只有滿足這個過濾條件的記錄才會被統計
調用舉例:table.Compute("Count(*)","Sex=0")
資料整理,非原創