The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
You can show RSS Feeds from 3rd party websites because RSS Feed data is in XML, so you just need to load it into a dataset, select a table from it, and bind it to a data-bound control. This article will discuss this process.
Installation
The sample code is available for this project above. Please copy and paste the code into your project. In the Web.config, paste this code in between the <toolboxControls> tags:
<add name="RadGridXMLFeed" section="Integration" url="~/UserControls/Integration/RadGridXMLFeed.ascx" |
description="RadGrid XML Feed" /> |
For more info on uploading controls, please read this article.
End Result
Once the control is dragged and dropped onto a page, here is the end result (using today's RSS Feed):
How it Works
When you click edit on the control, a dialog with a text box appeared. I used a control designer for this feature and for more info on creating these designers, please read this blog post.
I created a method for taking in an RSS Feed location, feeding the XML data into a data set and selecting a table to bind a RadGrid. Here is the code:
RadGridXML.ascx.cs
using System; |
using System.Data; |
using Telerik.Web.UI; |
[Telerik.Framework.Web.Design.ControlDesigner("CustomDesigner")] |
public partial class RadGridXMLFeed : CustomControlBase |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource); |
} |
void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
{ |
//Make sure an RSS Feed has been specified before binding the data |
if (!String.IsNullOrEmpty(MyNewsFeed)) |
{ |
BindGrid(MyNewsFeed, 3, RadGrid1); |
} |
else |
{ |
ErrorLabel.Text = "Please specify an RSS Feed for this control."; |
} |
} |
/// <summary> |
/// Binds grid to XML data source of rss feed |
/// </summary> |
/// <param name="strRss"></param> |
/// <param name="iTable"></param> |
/// <param name="RadGrid1"></param> |
public void BindGrid(string strRss, int iTable, RadGrid RadGrid1) |
{ |
try |
{ |
//Make sure an RSS Feed has been specified before binding the data |
if (!String.IsNullOrEmpty(strRss)) |
{ |
DataSet Ods = new DataSet(); |
Ods.ReadXml(strRss); |
RadGrid1.DataSource = Ods.Tables[iTable]; |
} |
} |
catch(Exception ex) |
{ |
ErrorLabel.Text = "I am sorry, but that RSS Feed won't work with this control. Please try another one."; |
} |
} |
} |
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.