asp.net翻页代码进不去,点击更多又返回到首页去了,,急
asp.net翻页代码进不去,点击更多又返回到首页去了,,急
这是更多后台代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
public partial class gengduo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.Redirect("index.aspx");
}
else
{
News n = new News();
string id = Request.QueryString["id"].ToString();
n.getNewsById(id);
Page.Title = n.newsTitle;
bd();
}
}
public void bd()
{
DAL.DataBase d = new DAL.DataBase();
DataSet ds = new DataSet();
d.runSQL("select * from news where newsID=" + Request["id"].ToString() + "order by newsID DESC", ref ds);
PagedDataSource p = new PagedDataSource();
p.DataSource = ds.Tables[0].DefaultView;
p.AllowPaging = true;
p.PageSize = 3;
int cp = 0;
if (Request["page"] != null)
{
cp = Convert.ToInt32(Request["page"]);
}
p.CurrentPageIndex = cp;
if (!p.IsFirstPage)
{
HyperLink1.NavigateUrl = "?id=" + Request["id"].ToString() + "&page=" + (cp - 1);
}
if (!p.IsLastPage)
{
HyperLink2.NavigateUrl = "?id=" + Request["id"].ToString() + "&page=" + (cp + 1);
}
HyperLink3.NavigateUrl = "?id=" + Request["id"].ToString() + "&page=" + 0;
HyperLink4.NavigateUrl = "?id=" + Request["id"].ToString() + "&page=" + (p.PageCount - 1);
showPage.Text = "第" + (p.CurrentPageIndex + 1) + "页共" + p.PageCount + "页";
DataList1.DataSource = p;
DataList1.DataBind();
d.close();
}
}
这是更多页面
加上这句话也不行DataSourceID="SqlDataSource1"
<asp:DataList ID="DataList1" runat="server">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="HyperLi" runat="server" Target="_blank" NavigateUrl='<%#Eval("newsID","shouNews.aspx?id={0}") %>' Text='<%#Eval("newsTitle").ToString().Length >17?Eval("newsTitle").ToString().Substring(0,15)+"...":Eval("newsTitle").ToString() %>'></asp:HyperLink>
<asp:Literal ID="Literal1" runat="server" Text='<%#"<i>"+Convert.ToDateTime(Eval("newsDate")).ToString("yyyy-MM-dd") +"</i>" %>'></asp:Literal>
</li>