一个关于分页的小问题,高分请教!着急啊!!!
我用的dataGrid控件,用的内置的默认导航按钮的分页模式
可我运行时 点下一页时 页面显示为空了
我的代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
where = "Colid="+Request.QueryString["cid"];
if (!IsPostBack)
MyConnection("Select * from CommInfo where "+where+" ORDER BY PubTime DESC");
}
private void MyConnection(string MySql)
{
OleDbConnection conn = new OleDbConnection(Application["connstr"].ToString());
conn.Open();
OleDbDataAdapter MyCommand = new OleDbDataAdapter(MySql, conn);
DataSet ds = new DataSet();
MyCommand.Fill(ds, "CommInfo");
DataView dv = ds.Tables["CommInfo"].DefaultView;
DataGrid1.DataSource = dv;
DataGrid1.DataBind();
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
MyConnection("Select * from CommInfo where "+where+" ORDER BY PubTime DESC");
}
非常简单的代码 应该没什么错啊 我用的是access数据库 我打开首页 第一页的数据能显示
请教阿!!!!