DataView data= DataSet.table[表名].DefaultView//你返回的dataset
data.RowFilter="字段名="+变量
datagrid.Datasourse=data;
datagrig.Databind();
DataView dv = ds.DataTable[0].DefaultView;
dv.RowFilter = "name='张三'";
dataGrid1.DataSource = dv;
想拿前n条记录:
DataTable table=yourTable.Clone();//克隆你现有表的结构
yourTable.DefaultView.RowFilter="id<" + count;
for(int i=0;i<n;i++)
{
DataRow newrow=yourTable.Rows[i];
table.Rows.Add(newrow);
}
data.RowFilter="字段名="+变量
datagrid.Datasourse=data;
datagrig.Databind();
DataView dv = ds.DataTable[0].DefaultView;
dv.RowFilter = "name='张三'";
dataGrid1.DataSource = dv;
想拿前n条记录:
DataTable table=yourTable.Clone();//克隆你现有表的结构
yourTable.DefaultView.RowFilter="id<" + count;
for(int i=0;i<n;i++)
{
DataRow newrow=yourTable.Rows[i];
table.Rows.Add(newrow);
}