Q:

Add class to last item

Possible Duplicate:
change repeater li item class if first or last 

Im working on a .net website which I've never worked with before.
I have the following that outputs 4 divs...
<asp:Repeater ID="RT_Ranges" runat="server">
    <ItemTemplate>
        <div class="item">
            <h4>
                <%# Eval("Category_Name")%></h4>
            <asp:Image ID="Image1" ImageUrl='<%# Eval("Img") %>' runat="server" Height="92" Width="79" />
            <p>
                <%# Eval("des") %></p>
            <asp:HyperLink ID="HL_More" NavigateUrl='<%# Eval("nav") %>' runat="server">View More</asp:HyperLink>
        </div>
    </ItemTemplate>
</asp:Repeater>

I want to add a class to the last DIV outputted from the above, is this possible and if so how would I do it? 

A:

You have your answer here
Make it like:
<asp:Repeater ID="RT_Ranges" runat="server">
    <ItemTemplate>
        <div class="<%# GetItemClass(Container.ItemIndex) %>">
            <h4>
                <%# Eval("Category_Name")%></h4>
            <asp:Image ID="Image1" ImageUrl='<%# Eval("Img") %>' runat="server" Height="92" Width="79" />
            <p>
                <%# Eval("des") %></p>
            <asp:HyperLink ID="HL_More" NavigateUrl='<%# Eval("nav") %>' runat="server">View More</asp:HyperLink>
        </div>
    </ItemTemplate>
</asp:Repeater>

and on your code-behind:
protected string GetItemClass(int itemIndex)
{
if (itemIndex == this.ItemCount - 1)
        return "CSS_for_last_item";

}

