方法为:

Code
private DataTable GetNewDataTable(DataTable dt, string condition)
{
DataTable newdt = new DataTable();
newdt = dt.Clone();
DataRow[] dr = dt.Select(condition);
for (int i = 0; i < dr.Length; i++)
{
newdt.ImportRow((DataRow)dr[i]);
}
return newdt;//返回的查询结果
}
调用的方法如下:

Code
GridView.DataSource = GetNewDataTable(payment.GetPayment().Tables[0], "state='" + State + "'");
GridView.DataBind();
//payment.GetPayment().Tables[0]为数据库检索出来的数据集
//State是一个字段名
//可写多个条件,用and,or连接
posted @
2009-01-16 17:02
希贝儿
阅读(
976)
评论()
收藏
举报