[求助]为什么gridview没有数据
我用下面的方法对gridview和DetailsView绑定同一数据:
OleDbConnection con=new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(".") + "\\app_data\\zxks.mdb");
con.Open();
OleDbCommand cmd =new OleDbCommand("select top 3 * from tk order by rnd(id)",con);
OleDbDataReader dr = cmd.ExecuteReader();
this.DetailsView1.DataSource = dr;
this.GridView1.DataSource = dr;
this.DetailsView1.DataBind();
this.GridView1.DataBind();
dr.Close();
con.Close();
为什么只有DetailsView有数据,而gridview没有呢?如果是我的方法不对那又如何实现?