Well, I suggested a ListView because it seems a lot easier than generating user controls on the fly and manage your own state. That's not to say that you have to use the ListView and that a UC is a bad practice; it all depends on your design and what you're trying to accomplish.
That said, ItemCreated is indeed a good place. Here's a quick example:
Code:
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
{
Label description = e.Item.FindControl("DescriptionLabel") as Label;
Picture picture = e.Item.DataItem as Picture;
if (picture != null)
{
if (picture.Id > 5)
{
description.CssClass = "Alert";
}
}
}
I am using FindControl to find a control inside the ItemTemplate. I then cast DataItem to the item I am binding to the control; a Picture in my case. When the picture is not null I am changing the appearance of the Label by assigning a CssClass. In this example, I am only doing that when the Id is > 5, but clearly this is just an example and you can apply any business logic you see fit.
Hope this helps,
Imar