System.Web.UI.WebControls.DataList.CreateItem Method

Creates a System.Web.UI.WebControls.DataListItem object.

Syntax

protected virtual DataListItem CreateItem (int itemIndex, ListItemType itemType)

Parameters

itemIndex
The specified location within the System.Web.UI.WebControls.DataList to place the created item.
itemType
A System.Web.UI.WebControls.ListItemType that represents the specified type of the item to create.

Returns

A new System.Web.UI.WebControls.DataListItem created with the specified list-item type.

Remarks

The DataList.CreateItem(int, ListItemType) method is used primarily by control developers in creating a custom implementation of the System.Web.UI.WebControls.DataList control. The DataList.CreateItem(int, ListItemType) method is functionally equivalent to calling the DataListItem.#ctor(int, ListItemType) constructor for a System.Web.UI.WebControls.DataListItem. The DataListItem.ItemIndex and DataListItem.ItemType properties are initialized for the new System.Web.UI.WebControls.DataListItem using the specified values, but the item is not inserted into the System.Web.UI.WebControls.DataList.

The DataList.CreateControlHierarchy(bool) method uses the DataList.CreateItem(int, ListItemType) and DataList.InitializeItem(DataListItem) methods to create System.Web.UI.WebControls.DataListItem controls that represent the header, footer, separator, and data-bound items contained in the data list. You can access the data-bound items for the data list through the DataList.Items collection. You can access all item types, including the header, footer, and separator items, through the BaseDataList.Controls collection.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0