我现在在做电子商务网站,用ASP.net做,怎么用Repeater控件进行分页?

解决方案 »

  1.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=D5C6E29D-99F5-44E8-4FED-75AF892A53CB
      

  2.   

    另外,你可以看一下我写的分页函数:    Public Function PageString(ByVal myPageSize As Integer, ByVal myTotalRecord As Integer, ByVal myPageNums As Integer, ByVal myPageUrl As String, ByVal Other As String) As String
            Dim myStr As String
            Dim TotalPage As Integer
            Dim i As Integer
            Dim Tmp As String
            If myTotalRecord = 0 Then Exit Function
            If myTotalRecord Mod myPageSize > 0 Then
                TotalPage = Fix(myTotalRecord / myPageSize) + 1
            Else
                TotalPage = myTotalRecord / myPageSize
            End If
            myStr += "共 " & myTotalRecord & " 条记录  每页 " & myPageSize & " 条记录   当前 " & myPageNums & "/" & TotalPage & " 页     "
            If Not myPageNums = 1 Then
                myStr += "[<a href=" & myPageUrl & "?Page=1" & Other & ">第一页</a>][<a href=" & myPageUrl & "?Page=" & Convert.ToString(myPageNums - 1) & Other & ">上一页</a>]"
            End If
            If Not myPageNums = TotalPage Then
                myStr += "[<a href=" & myPageUrl & "?Page=" & Convert.ToString(myPageNums + 1) & Other & ">下一页</a>][<a href=" & myPageUrl & "?Page=" & TotalPage & Other & ">最后页</a>]"
            End If
            myStr += "&nbsp; <select name=Page onchange=window.location='" & myPageUrl & "?Page='+this.value+'" & Other & "'>"
            For i = 1 To TotalPage
                Tmp += "<option value=" & i & ""
                If i = myPageNums Then Tmp += " selected"
                Tmp += ">" & i & "</option>"
            Next
            myStr += Tmp & "</select>"
            Return myStr
        End Function
      

  3.   

    可以用分页控件,呵呵aspnetpager
      

  4.   

    PagedDataSource objpage=new PagedDataSource();
    objpage.DataSource=ds.Tables["PU_friend"].DefaultView;
    objpage.AllowPaging=true;
    objpage.PageSize=12;
    int curpage;
    if(Request.QueryString["Page"]!=null)
    curpage=Convert.ToInt32(Request.QueryString["Page"]);
    else
    curpage=1;
    objpage.CurrentPageIndex=curpage-1;
    if(objpage.IsFirstPage&&!objpage.IsLastPage)
    {
    this.hlProv.Enabled=false;
    this.hlNext.NavigateUrl="Qw_morephotos.aspx?page="+Convert.ToInt32(curpage+1);
    this.hlFirst.Enabled=false;
    this.hlLast.NavigateUrl="Qw_morephotos.aspx?page="+Convert.ToInt32(objpage.PageCount);
    }
    else
    {
    if(objpage.IsLastPage&&!objpage.IsFirstPage)
    {
    this.hlFirst.NavigateUrl="Qw_morephotos.aspx?page="+1;
    this.hlLast.Enabled=false;
    this.hlNext.Enabled=false;
    this.hlProv.NavigateUrl="Qw_morephotos.aspx?page="+Convert.ToInt32(curpage-1);
    }
    else
    {
    if(objpage.IsFirstPage&&objpage.IsLastPage)
    {
    this.hlLast.Enabled=false;
    this.hlNext.Enabled=false;
    this.hlProv.Enabled=false;
    this.hlFirst.Enabled=false;
    }
    else
    {
    this.hlFirst.NavigateUrl="Qw_morephotos.aspx?page="+1;
    this.hlLast.NavigateUrl="Qw_morephotos.aspx?page="+Convert.ToInt32(objpage.PageCount);
    this.hlNext.NavigateUrl="Qw_morephotos.aspx?page="+Convert.ToInt32(curpage+1);
    this.hlProv.NavigateUrl="Qw_morephotos.aspx?page="+Convert.ToInt32(curpage-1);
    }
    }
    }
    this.dlHot.DataSource=objpage;
    this.dlHot.DataBind();