In this article, I'll show a code snippet I made in order to create a small blog using the web feed provided by another blog engine.
Let's see the snippet that retrieves the data from the feed:
protected void dataBind()
XmlTextReader reader =
DataSet ds = new DataSet();
GridView1.DataSource = ds.Tables;
dataBind() opens the file rss.xml using a
XmlTextReader, puts the content in a
DataSet and sets one of the tables of the dataset to the
GridView I used to show the data.
This is the code I made to modify the look and feel of the
<asp:GridView ID="GridView1" runat="server"
<h1><%# Eval("title") %></h1>
<h4><%# Eval("pubDate")%></h4><br />
<%# Eval("description")%><br /><br />
GridView doesn't handle the paging of the XML data source by default. So, I needed to add the following method to handle the paging:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
GridView1.PageIndex = e.NewPageIndex;
This is the result I had calling
dataBind() on page load and using an elegant CSS:
- [2-OCT-2007]: First version of the XML parser classes released
- [4-OCT-2007]: Added source files
- [31-OCT-2011]: Main revision of the article, the code is the same as before