最近在使用iframe框架实现新闻页面是遇到如下问题:
新闻主页面是news.aspx,其子页面是News_inner.aspx
子页面中有一个打datalist呈现文章标题,并对标题分页
分页代码如下:
if (Request.QueryString["cid"] !=null)
{
int classid = Convert.ToInt32(Request.QueryString["cid"]);//classid为类别标签
string sql = "select ID,title = SUBSTRING(title,0,20),ModDate from rm_Article where classid = '" + classid + "' order by ID DESC";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;//是否可以分页
pds.PageSize = 5;
int curpage;
if (Request.QueryString["Page"] != null)
curpage = Convert.ToInt32(Request.QueryString["Page"]);
else
curpage = 1; pds.CurrentPageIndex = curpage - 1;
PageShow.Text = "当前页:" + curpage.ToString();
if (!pds.IsFirstPage)
PreLink.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curpage - 1);
if (!pds.IsLastPage)
NextLink.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curpage + 1); TitleList.DataSource = pds;
TitleList.DataBind();
}
这样做后,只能显示第一页的标题,以后页面为空。
我调试发现,每次单机下一页时,Request.QueryString["cid"] =null ,请问大家怎么解决啊?
新闻主页面是news.aspx,其子页面是News_inner.aspx
子页面中有一个打datalist呈现文章标题,并对标题分页
分页代码如下:
if (Request.QueryString["cid"] !=null)
{
int classid = Convert.ToInt32(Request.QueryString["cid"]);//classid为类别标签
string sql = "select ID,title = SUBSTRING(title,0,20),ModDate from rm_Article where classid = '" + classid + "' order by ID DESC";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;//是否可以分页
pds.PageSize = 5;
int curpage;
if (Request.QueryString["Page"] != null)
curpage = Convert.ToInt32(Request.QueryString["Page"]);
else
curpage = 1; pds.CurrentPageIndex = curpage - 1;
PageShow.Text = "当前页:" + curpage.ToString();
if (!pds.IsFirstPage)
PreLink.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curpage - 1);
if (!pds.IsLastPage)
NextLink.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curpage + 1); TitleList.DataSource = pds;
TitleList.DataBind();
}
这样做后,只能显示第一页的标题,以后页面为空。
我调试发现,每次单机下一页时,Request.QueryString["cid"] =null ,请问大家怎么解决啊?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货