我的gridview在过滤时没有显示数据
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection conn=new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Dynacs.accdb");
OleDbDataAdapter da = new OleDbDataAdapter("select empname,pass,status from employees", conn);
DataSet ds = new DataSet();
da.Fill(ds, "emp");
GridView1.DataSource = ds.Tables["emp"].Select("status='in'");
GridView1.DataBind();
}
答案 0 :(得分:0)
OleDbDataAdapter da = new OleDbDataAdapter("select empname,pass,status from employees", conn);
DataSet ds1=new DataSet();
da.Fill(ds1,"emp");
var datasource = from r in ds1.Tables["emp"].AsEnumerable()
where r.Field<string>("status")=="out"
select new{empname=r.Field<String>("empname"),status=r.Field<string>("status")};
GridView1.DataSource = datasource;
GridView1.DataBind();