Pretty RSS Feed Display

This demo illustrates displaying the RSS <item> elements from a remote RSS feed using a DataGrid. This demo differs from the previous demo in that the DataGrid's aesthetic properties are set so that the appearance is more eye-pleasing. (Also note that the data shown in this demo is a snapshot of the RSS feed's data from Monday, March 17th. A static RSS feed is used to reduce load on the ASPMessagboard.com server.)


20 Most Recent ASPMessageboard.com Posts
What's New in ASP.NET 4.5 and Visual Studio 2012 (Fri, 19 Aug 2016 13:33:46 -0700)
Getting Started with ASP.NET Web API (Tue, 19 Jul 2016 19:58:33 -0700)
Getting Started with ASP.NET MVC (Tue, 19 Jul 2016 19:45:34 -0700)
Introducing ASP.NET Web Pages (Tue, 19 Jul 2016 19:42:21 -0700)
Getting Started with ASP.NET Web Forms (Tue, 19 Jul 2016 19:40:18 -0700)
ASP.NET 4.5 and Visual Studio 2012 (Tue, 21 Jun 2016 20:24:26 -0700)
ASP.NET Identity Tips (Video) (Tue, 21 Jun 2016 19:06:03 -0700)
ASP.NET Identity: Two-Factor Authentication (Video) (Tue, 21 Jun 2016 19:05:27 -0700)
ASP.NET Identity (dotnetConf 2014) (Tue, 21 Jun 2016 19:04:28 -0700)
Azure Active Directory Video Series (Tue, 21 Jun 2016 19:03:41 -0700)
Introduction to ASP.NET Identity (Video) (Tue, 21 Jun 2016 19:02:49 -0700)
ASP.NET Identity Videos (Tue, 21 Jun 2016 18:59:32 -0700)
ASP.NET SignalR Videos (Tue, 21 Jun 2016 18:58:26 -0700)
ASP.NET Web API Videos (Tue, 21 Jun 2016 18:57:17 -0700)
ASP.NET MVC Videos (Tue, 21 Jun 2016 18:55:18 -0700)
ASP.NET Web Forms Videos (Tue, 21 Jun 2016 18:53:22 -0700)
ASP.NET Web Pages Videos (Tue, 21 Jun 2016 18:52:39 -0700)
ASP.NET 3.5 and Visual Studio 2008 (Tue, 21 Jun 2016 11:52:04 -0700)
ASP.NET 4 and Visual Studio 2010 (Tue, 21 Jun 2016 11:51:39 -0700)
ASP.NET 4.5 and Visual Studio 2012 (Tue, 21 Jun 2016 11:51:18 -0700)


Source Code
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data" %>
<script language="VB" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    recentPosts.DataSource = GetRSSFeed("http://www.asp.net/news/rss.ashx")
    recentPosts.DataBind()      
  End Sub


  Function GetRSSFeed(strURL as String) as DataTable
    'Get the XML data
    Dim reader as XmlTextReader = New XmlTextReader(strURL)
    
    'return a new DataSet
    Dim ds as DataSet = New DataSet()
    ds.ReadXml(reader)    
    Return ds.Tables(2)
  End Function
</script>
  
<asp:DataGrid runat="server" id="recentPosts" AutoGenerateColumns="False"
     Font-Name="Arial" Font-Size="10pt"
     HeaderStyle-Font-Bold="True"
     HeaderStyle-HorizontalAlign="Center"
     HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
     HeaderStyle-Font-Size="15pt"
     AlternatingItemStyle-BackColor="#eeeeee">
  <Columns>
    <asp:TemplateColumn HeaderText="20 Most Recent ASPMessageboard.com Posts">
      <ItemTemplate>
        <a href="<%# DataBinder.Eval(Container.DataItem, "link")%>">
          <%# DataBinder.Eval(Container.DataItem, "title") %>
        </a> (<i><%# DataBinder.Eval(Container.DataItem, "pubDate") %></i>)
      </ItemTemplate>
    </asp:TemplateColumn>
  </Columns>
</asp:DataGrid>

[Return to the article]