This documentation is archived and is not being maintained.

ListViewDataItem Class

Represents an individual data item in a ListView control.

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

[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class ListViewDataItem : public ListViewItem, 
	IDataItemContainer, INamingContainer
<asp:ListViewDataItem />

The ListViewDataItem class represents an individual data item in a ListView control. A data item usually corresponds to a record in a data source object. The class derives from the ListViewItem class.

Each item in the ListView control has a designated item type that is represented by the ItemType property. When the item type is ListViewItemType::DataItem, you can use the ListViewDataItem class to get more information about the item.

The ListView control stores data items in the Items collection. To determine the index of a ListViewDataItem object in the Items collection, use the DisplayIndex property. To determine the index of the data item in the underlying data source, use the DataItemIndex property. The difference between these index properties is that DisplayIndex represents the position of the data item in the current page, whereas DataItemIndex is based on the page offset. If the paging functionality is not enabled in the ListView control by using a DataPager control, these two properties will contain the same value.

You can access the properties of the underlying data object by using the DataItem property.

The DataItem property is available only during and after the ItemDataBound event of a ListView control.

For a list of initial property values for an instance of the ListViewDataItem class, see the ListViewDataItem constructor.

The following example shows how to use a ListViewDataItem object to retrieve a field value from an item in the ListView control.

Security noteSecurity Note:

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

No code example is currently available or this language may not be supported.

System::Object
  System.Web.UI::Control
    System.Web.UI.WebControls::ListViewItem
      System.Web.UI.WebControls::ListViewDataItem

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5
Show: