I needed to display a news feed from an xml file. My original intentions were to use XML & XSL to tranform into html but i needed paging support.
I looked at the XMLData Source control and there isno paging support built onto this control. After a look around I came across a .NET class called PagedDataSource. This class abstracts the paging functionality that is used in data grids etc.
All you have to do is load the XML into a dataset, load the pageddatasource with the data from the dataset, set the paging on, set the page index and items per page. Voila! This can now be bound to any control that supports data binding. Wicked!
Here is some sample code binding it to a DataRepeater.
Dim ds As New DataSetds.ReadXml("Data.xml")Dim pagedData As New PagedDataSourceDim dv As New DataView(ds.Tables(0))dv.Sort = "SortDate DESC"pagedData.DataSource = dvpagedData.AllowPaging = TruepagedData.PageSize = ItemsPerPagepagedData.CurrentPageIndex = CurrentIndexxmlRepeater.DataSource = pagedDataxmlRepeater.DataBind()btnBack.Visible = Not pagedData.IsFirstPagebtnMore.Visible = Not pagedData.IsLastPage

No comments:
Post a Comment