Vous pouvez accéder à la propriété Item ListViewItemEventArgs pour accéder à l'élément en cours (celui lié aux données).
Le code exemple ci-dessous (qui montre comment personnaliser un élément ListView en cas ItemDataBound) a été prise du MSDN documentation:
protected void ContactsListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{
Label EmailAddressLabel;
if (e.Item.ItemType == ListViewItemType.DataItem)
{
// Display the e-mail address in italics.
EmailAddressLabel = (Label)e.Item.FindControl("EmailAddressLabel");
EmailAddressLabel.Font.Italic = true;
System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;
string currentEmailAddress = rowView["EmailAddress"].ToString();
if (currentEmailAddress == "[email protected]")
{
EmailAddressLabel.Font.Bold = true;
}
}
}
Merci cette méthode FindControl est ce que je avais besoin, a travaillé un régal! – NibblyPig