ListViewItemEventArgs.Item Property

 

Gets the item that is being created or bound to data.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public ListViewItem Item { get; }

Property Value

Type: System.Web.UI.WebControls.ListViewItem

The item that is being created or bound to data.

Use the Item property to access the properties of the item that is being created or bound to data. To determine which item type (data item, empty item, or insert item) is being created, use the ItemType property of the ListViewItem object.

The following example shows how to use the Item property to access the properties of the item that is being bound to data. This code example is part of a larger example provided for the ListViewItemEventArgs class.

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 == "orlando0@adventure-works.com")
        {
            EmailAddressLabel.Font.Bold = true;
        }
    }
}

.NET Framework
Available since 3.5
Return to top
Show: