Showing 3rd Party RSS Feeds

Showing 3rd Party RSS Feeds

Posted on May 21, 2009 0 Comments

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.

**Sample Code is Available Here**

 

Introduction

 

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.";  
        } 
    } 
 

To get an RSS feed from Thomson Reuters, follow these steps:

 

  1. Go to this URL: http://uk.reuters.com/tools/rss
  2. Right click on an RSS Feed
  3. Select Copy Link location
  4. Copy and paste the link into the control designer as shown below:
control desginer


progress-logo

The Progress Team

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.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation