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

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? .NET, ADO.NET, ASP.NET, AJAX, Atlas, Microsoft AJAX Library, ASP.NET 2.0 AJAX Extensions, ............

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

About wallym

Wallace B. (Wally) McClure INETA Speaker's Bureau Microsoft MVP ASPInsider Co-author of "Beginning AJAX with ASP.NET" Co-author of "Professional ADO.NET Programming" Co-author of "Building Highly Scalable Database Applications with .NET" Master's Degree in Electrical Engineering from Georgia Tech Bachelor's Degree in Electrical Engineering from Georgia Tech
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems