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
StorageModelBuildProvider.GetResultFlags(CompilerResults) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
StorageModelBuildProvider Class (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityModelBuildProvider.GenerateCode(AssemblyBuilder) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
MappingModelBuildProvider.GenerateCode(AssemblyBuilder) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityDesignerBuildProvider Class (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityDesignerBuildProvider.GenerateCode(AssemblyBuilder) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
MappingModelBuildProvider Class (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityModelBuildProvider Constructor (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
StorageModelBuildProvider Constructor (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityModelBuildProvider Class (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
StorageModelBuildProvider.GenerateCode(AssemblyBuilder) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
System.Data.Entity.Design.AspNet Namespace (Sun, 20 Jan 2019 02:33:39 GMT)
EntityDesignerBuildProvider.GetResultFlags(CompilerResults) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
MappingModelBuildProvider.GetResultFlags(CompilerResults) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityModelBuildProvider.GetResultFlags(CompilerResults) Method (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
MappingModelBuildProvider Constructor (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
EntityDesignerBuildProvider Constructor (System.Data.Entity.Design.AspNet) (Sun, 20 Jan 2019 02:33:39 GMT)
WhiteSpaceTrimStringConverter Class (System.Configuration) (Sun, 20 Jan 2019 02:33:33 GMT)
TypeNameConverter Class (System.Configuration) (Sun, 20 Jan 2019 02:33:33 GMT)
TimeSpanMinutesConverter Class (System.Configuration) (Sun, 20 Jan 2019 02:33:33 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]