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
XhtmlTextWriter Class (System.Web.UI) (Thu, 17 Jan 2019 08:13:27 GMT)
WebResourceAttribute.PerformSubstitution Property (System.Web.UI) (Thu, 17 Jan 2019 08:13:27 GMT)
Xml.AddParsedSubObject(Object) Method (System.Web.UI.WebControls) (Thu, 17 Jan 2019 08:13:27 GMT)
Xml.Render(HtmlTextWriter) Method (System.Web.UI.WebControls) (Thu, 17 Jan 2019 08:13:26 GMT)
WebResourceAttribute.WebResource Property (System.Web.UI) (Thu, 17 Jan 2019 08:13:26 GMT)
WebResourceAttribute Class (System.Web.UI) (Thu, 17 Jan 2019 08:13:26 GMT)
WebResourceAttribute.ContentType Property (System.Web.UI) (Thu, 17 Jan 2019 08:13:26 GMT)
WebZone Class (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:26 GMT)
WebPartZoneBase.HelpVerb Property (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartZone Constructor (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartZoneBase.OnCreateVerbs(WebPartVerbsEventArgs) Method (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartZone Class (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartVerb.Text Property (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartZoneBase.CreateVerbs Event (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartVerb.Enabled Property (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartTransformer Class (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartVerb.ImageUrl Property (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartVerb Class (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartVerb.Description Property (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 GMT)
WebPartManager Class (System.Web.UI.WebControls.WebParts) (Thu, 17 Jan 2019 08:13:25 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]