string str = "select * from Users ";
SqlCommand cmd = new SqlCommand(str, conn);
DataSet ds = new DataSet();
SqlDataAdapter das = new SqlDataAdapter();
das.SelectCommand = cmd;
das.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "UserID>0and UserID<2";
DataList1.DataSource = dv;
DataList1.DataBind();
格式就是这样。。。dv.RowFilter = "UserID>0and UserID<2";
这个是判断你那个字段UserID的显示范围,你稍修改下就OK了。。
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "ID>3 and ID<10";
this.rep_new.DataSource = dv;
this.rep_new.DataBind();
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "ID>3 and ID<10";