新手问分页问题
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>
<%@ import namespace= "System.Data " %>
<%@ Import Namespace= "System.Data.SqlClient " %>
<script language= "C# " runat= "server ">
public void Page_Load(Object sender, EventArgs e)
{
string connec = "user id=sa;password=123;initial catalog=SQLStarnew;Server=KEYJOB;Connect TimeOut=120; ";
SqlConnection objConn = new SqlConnection(connec);
objConn.Open();
string Sqlstr = "select * from StarName ";
SqlCommand Command = new SqlCommand(Sqlstr, objConn);
System.Data.SqlClient.SqlDataAdapter objCommand = new System.Data.SqlClient.SqlDataAdapter(Command);
DataSet ds=new DataSet();
objCommand.Fill(ds);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 2;
int CurPage;
if (Request.QueryString[ "Page "] != null)
CurPage=Convert.ToInt32(Request.QueryString[ "Page "]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "当前页: " + CurPage.ToString();
if (!objPds.IsFirstPage)
lnkfirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1 ";
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?Page= " + Convert.ToString(CurPage-1);
if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page= " + Convert.ToString(CurPage+1);
if (!objPds.IsLastPage)
lnkend.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=???? ";
Repeater1.DataSource=objPds;
Repeater1.DataBind();
}
</script>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head id= "Head1 " runat= "server ">
<title> Repeater控件分页的例子 </title>
</head>
<body>
<form id= "Form1 " method= "POST " runat= "server ">
<div style= "padding:5px;background-color:#dedede ">
<asp:label ID= "lblCurrentPage " runat= "server "> </asp