DataList Databinding - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

News

Please goy buy 3-4 copies of my book on MonoTouch titled "Professional iPhone Programming with MonoTouch for .NET/C# Developers." They make great gifts all year round. Plus, I get about $.20 when you buy a copy.

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? iPhone, Android, MonoTouch, MonoDroid, Mobile, HTML5, .NET, ADO.NET, ASP.NET, AJAX, Atlas, Microsoft AJAX Library, ASP.NET AJAX, and Windows Azure............follow me on twitter at Wally

DataList Databinding

I have recently been writing a new feature for an ASP.NET 1.1 application.  In it, I have a datalist which I bind data to.  My datalist is defined with a rather simple header, item, and footer templates.  When I was capturing the OnitemDataBound event and processing the databinding of each individual row, I was getting this really weird error.  The issue is that the Header (and I assume the Footer) bindings are also within the OnItemDataBound event.  As a result, it is necessary to trap and look for what the binding type is.  An example is below.  This example will catch .Item and .AlternatingItem.  Some of the other ListItemTypes are:
  • EditItem.
  • Header.
  • Footer.
  • Pager.
  • Separator.
  • SelectedItem.
  • Separator.

If you are trying to do some databinding with a DataList in .NET 1.1, I hope that this was helpful.

Public Sub dlStaff_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs)
   If ((e.Item.ItemType = ListItemType.Item) OrElse (e.Item.ItemType = ListItemType.AlternatingItem)) Then
      'Do something here
   End If
End Sub

Comments

 

Wallace B. McClure said:

July 20, 2006 5:49 PM
 

Wallace B. McClure said:

July 20, 2006 5:52 PM
 

ASP.NET Podcast said:



Subscribe
– Everybody is doing it



Download
– The wimpy way.



Show Notes:

Star ...
July 28, 2006 10:56 AM
 

Weblog said:

October 13, 2006 4:19 PM
 

ASP.NET Podcast said:

Subscribe – Everybody is doing it This show is available in the subscription feed. Show Notes: Star Trek/2.0
December 20, 2006 8:27 PM
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems