Link to home
Start Free TrialLog in
Avatar of AidenA
AidenA

asked on

implementing paging in xml data using a DataList (.NET 2.0)

Hi, I was looking the web for info on this but couldn't get it working. I got as far as below

html
 <asp:DataList  ID="DataList1"  runat="server" style="border:1px solid; border-color:#68affd;"></asp:DataList>

Open in new window


Codebehind: I've removed a bit of the code to just show the loading.
Private Sub LoadXML()

        Dim Items As New Data.DataSet()
        Items.ReadXml("http://ipaddress/news.xml")

        'creating the PagedDataSource instance....
        Dim pg As New PagedDataSource()
        Dim dv As New Data.DataView(Items.Tables(0))

        pg.DataSource = dv 

        pg.AllowPaging = True
        pg.PageSize = 1

        pg.CurrentPageIndex = 0
        'pg.CurrentPageIndex = CurrentIndex

        'The currentpage
        lblIndex.Text = "Page: " + (CurrentIndex + 1).ToString() + " of " + pg.PageCount.ToString()

        'Button status
        'Button1.Enabled = Not pg.IsFirstPage
        'Button2.Enabled = Not pg.IsLastPage


        'Binding pg to datalist
        DataList1.DataSource = pg 'dl is datalist
        DataList1.DataBind()

    End Sub

Open in new window


The problem that I'm having there is that nothing is returned at all even though the xml page does have data on it. What am I doing wrong there do you know?
ASKER CERTIFIED SOLUTION
Avatar of Member_2_4913559
Member_2_4913559
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AidenA
AidenA

ASKER

That was perfect, thanks!