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
Truly FUNNY! (Bill Wilkinson) (3/17/2003 5:46:20 PM)
And I repeat the question <eom> (Bill Wilkinson) (3/17/2003 5:43:50 PM)
Web Service / File transfer. (helpme07) (3/17/2003 5:41:12 PM)
RE: LOL! Yeah, it's kind of esoteric... (Francis Leyland) (3/17/2003 5:40:47 PM)
RE: HOW do you display it? (jholmes) (3/17/2003 5:38:43 PM)
With XP it is automatic... (Bill Wilkinson) (3/17/2003 5:36:08 PM)
RE: God, this is close right?? (rachelmnms) (3/17/2003 5:34:40 PM)
HOW do you display it? (Bill Wilkinson) (3/17/2003 5:31:31 PM)
Click on Customize Forum Display (Bill Wilkinson) (3/17/2003 5:29:46 PM)
display of null from database (jholmes) (3/17/2003 5:28:23 PM)
Not that I know of... (Bill Wilkinson) (3/17/2003 5:27:49 PM)
bigger text (Chaotix) (3/17/2003 5:27:00 PM)
Auto email from microsoft? (Chaotix) (3/17/2003 5:25:56 PM)
RE: Plus no need to use this (youeee) (3/17/2003 5:22:52 PM)
RE: Nope...can't find a way... (jholmes) (3/17/2003 5:20:40 PM)
Yes, but... (Bill Wilkinson) (3/17/2003 5:18:54 PM)
Nope...can't find a way... (Bill Wilkinson) (3/17/2003 5:14:36 PM)
Easy .xml to .xsl to .xml again?? (rachelmnms) (3/17/2003 5:05:37 PM)
Hyper link column in a datagrid??? (gummadilli) (3/17/2003 4:54:40 PM)
RE: Damn...& Blast (sip1976) (3/17/2003 4:51:26 PM)


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.aspmessageboard.com/scripts/rss.xml")
    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, "datePosted") %></i>)
      </ItemTemplate>
    </asp:TemplateColumn>
  </Columns>
</asp:DataGrid>

[Return to the article]