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
Community Videos and Blogs (Fri, 22 Jun 2018 22:08:58 GMT)
Visual Studio 2017 15.6 Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 15.0 Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 15.5 Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 Preview Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 for Mac - Preview Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 Preview Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2015 Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 Preview Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2017 Version 15.3 Preview Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2013 Update 3 (2013.3) Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2013 Update 2 RTM Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2015 Update 1 (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2013 Update 4 (2013.4) RC Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2013 Update 4 Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Visual Studio 2010 Service Pack 1 Release Notes (Fri, 22 Jun 2018 21:22:33 GMT)
Add a model to a Razor Pages app in ASP.NET Core (Fri, 22 Jun 2018 20:24:29 GMT)
Use streaming in ASP.NET Core SignalR (Fri, 22 Jun 2018 20:24:29 GMT)
Migrate from ASP.NET Web API to ASP.NET Core (Fri, 22 Jun 2018 20:24:29 GMT)
Initiate HTTP requests (Fri, 22 Jun 2018 20:24:28 GMT)


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]