How can I access the last item in a DataList in order to set its class?
<p>I need to create buttons for each item in a DataList, but the last button needs to be formatted differently, so it needs a different css class applied to it.</p>

<p>I think this should be done in the OntemDataBound method, but feel free to correct me if I'm wrong.</p>

<p>I want to do something like this:</p>

<pre><code>protected void dlDataList_ItemDataBound(object sender, DataListItemEventArgs e)
{
  if (e.Item.ItemIndex == dlDataList.Items.Count - 1) //This doesn't work like I'd hoped
  {
    Panel button = (Panel)e.Item.FindControl("btnButton");
    button.CssClass = ("altClass");
  }
  ...
}
</code></pre>

<p>The problem is, I don't think the datalist knows how many items it will have in the ItemDataBound event because dlDataList.Items.Count is always the same as the ItemIndex.</p>

<p>Any ideas on how I can give the last button the altClass css class?</p>
