Simple Data Binding Tutorial

Jun 28, 2007 at 8:38 PM
Edited Jun 28, 2007 at 8:40 PM

This is a simple tutorial to binding to a control. In this case we will create a datalist and bind to it upon page load


aspx

<asp:DataList ID="dlItems" runat="Server">
<ItemTemplate>
<h4><%# Eval("Title") %></h4>
<p>
<%# Eval("Content") %>
</p>
</ItemTemplate>
</asp:DataList>

c#
protected void Page_Load(object sender, EventArgs e)
{
string feedUri = "http://feeds.feedburner.com/getanewbrowser";

FeedDotNet.Common.Feed feed = FeedDotNet.FeedReader.Read(feedUri);

this.dlItems.DataSource = feed.Items;
this.dlItems.DataBind();
}
Jun 28, 2007 at 8:40 PM
Sorry, I'm not quite sure how to format code on here.