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
Azure Active Directory code samples (Wed, 17 Oct 2018 22:18:28 GMT)
ASP.NET Core tutorials (Wed, 17 Oct 2018 21:11:35 GMT)
Add search to an ASP.NET Core MVC app (Wed, 17 Oct 2018 21:11:35 GMT)
Format response data in ASP.NET Core Web API (Wed, 17 Oct 2018 21:11:35 GMT)
Azure Key Vault configuration provider in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Add search to an ASP.NET Core MVC app (Wed, 17 Oct 2018 21:11:35 GMT)
Get started with ASP.NET Core MVC and Visual Studio (Wed, 17 Oct 2018 21:11:35 GMT)
ASP.NET Core SignalR configuration (Wed, 17 Oct 2018 21:11:35 GMT)
Add search to an ASP.NET Core MVC app (Wed, 17 Oct 2018 21:11:35 GMT)
Security considerations in ASP.NET Core SignalR (Wed, 17 Oct 2018 21:11:35 GMT)
Integration tests in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Razor Pages unit tests in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Introduction to ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Razor Pages authorization conventions in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Application startup in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Custom Model Binding in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Filters in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Filter methods for Razor Pages in ASP.NET Core (Wed, 17 Oct 2018 21:11:35 GMT)
Custom storage providers for ASP.NET Core Identity (Wed, 17 Oct 2018 21:11:35 GMT)
What's new in ASP.NET Core 1.1 (Wed, 17 Oct 2018 21:11:35 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]