Page view counter

Paging in datalist??

Last post 10-18-2006 2:04 AM by rexlin. 2 replies.

Sort Posts:

  • Paging in datalist??

    10-18-2006, 12:43 AM
    • Loading...
    • khushak
    • Joined on 08-21-2006, 9:21 AM
    • gurgaon, India
    • Posts 193
    • Points 549

    Hi,

    In my asp.net page i am using datalist and i want to paging but i am not find the any propertie onf paging in datalist i am using .net 1.1.

    is 1.1 not provide the paging in datalist

    if yes then how??

    regard

     

    New In .NET World
  • Re: Paging in datalist??

    10-18-2006, 1:48 AM
    • Loading...
    • yyy8347
    • Joined on 09-19-2006, 11:00 AM
    • Posts 703
    • Points 3,592

    1.1 does not provide the paging in datalist. the DataGrid control—natively supports paging .

    But you can create a Pager Control for DataList . See Creating a Pager Control for ASP.NET .

    Sincerely,
    Young Fang
  • Re: Paging in datalist??

    10-18-2006, 2:04 AM
    Answer
    • Loading...
    • rexlin
    • Joined on 07-17-2006, 4:43 AM
    • Posts 1,751
    • Points 9,363

    Hi,khushak:

    You can use PagedDataSource. Here is the sample: 

    Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
     2       

     3        Dim sqlconn As New SqlConnection(ConfigurationSettings.AppSettings.Get("sqlserver"))
     4        sqlconn.Open()
     5        Dim sqlda As New SqlDataAdapter("select * from vote_items", sqlconn)
     6        Dim dt As New DataTable
     7        sqlda.Fill(dt)
     8        sqlda.Dispose()
     9
    10        
    11        Dim pds As New PagedDataSource
    12       

    13        

    14        pds.DataSource = dt.DefaultView
    15        '==================================================
    16        pds.AllowPaging = True
    17        pds.PageSize = 3 
    18
    19        

    20        Dim currentpage As Integer
    21        If Request.QueryString.Get("page"<> Nothing Then
    22            currentpage = Convert.ToInt32(Request.QueryString("Page"))
    23        Else
    24            currentpage = 1
    25        End If
    26        

    27        pds.CurrentPageIndex = currentpage - 1
    28
    29        Label1.Text = "共有记录" & pds.DataSourceCount & "条,分" & pds.PageCount & "页显示,每页显示" & _
    30        pds.PageSize & "条,当前为第" & currentpage & "页:"
    31
    32        
    33        If Not pds.IsFirstPage Then
    34            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToInt32(currentpage - 1)
    35            lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=1"
    36        End If
    37
    38        If Not pds.IsLastPage Then
    39            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToInt32(currentpage + 1)
    40            lnkLast.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & pds.PageCount
    41        End If
    42
    43        '

    44        rp.DataSource = pds
    45        rp.DataBind()



    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    This posting is provided "AS IS" with on warranties, and confers no rights.
Page 1 of 1 (3 items)