This project has moved. For the latest updates, please go here.

Paging with RSS Toolkit

Topics: Developer Forum, User Forum
Mar 22, 2008 at 8:31 PM
This code loads all data from RSS feed:

//TODO: Load here only page number pageIndex, load only numRows for that page
//Now it is loading all records!
d = RssToolkit.Rss.RssDocument.Load(new Uri(url));
dv1 = (DataView)d.SelectItems();

I would like to load only specific page of data, so not all data are loaded. What if RSS Feed has 10,000 rows??? How to do it? Here is my whole method for loading data:

DataTable GetDataSource(string keyWord, int pageIndex, int numRows)
{
DataTable retValue = new DataTable();
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Server.MapPath(_xmlUrlsFileName));

XmlNode xNode = xDoc.SelectSingleNode("RSSURLS");
foreach (XmlNode xUrlNode in xNode.ChildNodes)
{
string url = string.Format(xUrlNode.Attributes"URL".Value, keyWord);
RssToolkit.Rss.RssDocument d;
DataView dv1;
try
{
//TODO: Load here only page number pageIndex, load only numRows for that page
//Now it is loading all records!
d = RssToolkit.Rss.RssDocument.Load(new Uri(url));
dv1 = (DataView)d.SelectItems();
}
catch { continue; }
if (retValue.Rows.Count == 0)
{
retValue = dv1.Table.Copy();
retValue.PrimaryKey = null;
}
else
{
foreach (DataRow dr in dv1.Table.Rows)
{
retValue.ImportRow(dr);
}
}
}

return retValue;
}
Mar 24, 2008 at 7:49 PM
You can use the PagedDataSource class as long as you are on .NET 2.0 or greater. http://www.devhood.com/tutorials/tutorialdetails.aspx?tutorialid=97 has a good example of it.