public DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ds = new DataSet();
GetDv();
this.DataListBind();
}
} private void GetDv() {
string str = String.Empty;
if (Request.QueryString["title"] == null)
str = "";
else
str = Request.QueryString["title"].ToString();
if (Request.QueryString["tablename"] != null)
ds = YsnRx.dc.SelDoubleDelve(Convert.ToString(Request.QueryString["tablename"]), str);
} //绑定DataList
private void DataListBind() {
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables["t_CompanyInfo"].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;
int CurPage;
if (Request.QueryString["page"] != null)
CurPage = Convert.ToInt32(Request.QueryString["page"]);
else
CurPage = 1;
if (!pds.IsFirstPage)
{
first.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + 1; 首页link链接
prev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurPage - 1); 上一页link链接
}
if (!pds.IsLastPage)
{
end.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + pds.PageCount; 尾页link
next.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurPage + 1); 下一页link链接
}
pds.CurrentPageIndex = CurPage - 1;
Response.Write(Convert.ToString(pds.CurrentPageIndex));
CurrentLbl.Text = CurPage.ToString();
PageSum.Text = pds.PageCount.ToString();
TotalLbl.Text = pds.DataSourceCount.ToString();
DataList1.DataSource = pds;
DataList1.DataBind();
}加载时候有数据,会显示,但翻页就没数据了。自己感觉是title传值那边有问题,因为我后面转本页时候没传title,tablename值,但是DataSet不是会缓存吗?不可能每次访问都加载一次吧?请问怎么处理?
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ds = new DataSet();
GetDv();
this.DataListBind();
}
} private void GetDv() {
string str = String.Empty;
if (Request.QueryString["title"] == null)
str = "";
else
str = Request.QueryString["title"].ToString();
if (Request.QueryString["tablename"] != null)
ds = YsnRx.dc.SelDoubleDelve(Convert.ToString(Request.QueryString["tablename"]), str);
} //绑定DataList
private void DataListBind() {
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables["t_CompanyInfo"].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;
int CurPage;
if (Request.QueryString["page"] != null)
CurPage = Convert.ToInt32(Request.QueryString["page"]);
else
CurPage = 1;
if (!pds.IsFirstPage)
{
first.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + 1; 首页link链接
prev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurPage - 1); 上一页link链接
}
if (!pds.IsLastPage)
{
end.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + pds.PageCount; 尾页link
next.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurPage + 1); 下一页link链接
}
pds.CurrentPageIndex = CurPage - 1;
Response.Write(Convert.ToString(pds.CurrentPageIndex));
CurrentLbl.Text = CurPage.ToString();
PageSum.Text = pds.PageCount.ToString();
TotalLbl.Text = pds.DataSourceCount.ToString();
DataList1.DataSource = pds;
DataList1.DataBind();
}加载时候有数据,会显示,但翻页就没数据了。自己感觉是title传值那边有问题,因为我后面转本页时候没传title,tablename值,但是DataSet不是会缓存吗?不可能每次访问都加载一次吧?请问怎么处理?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货