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

Supported in: 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft