ListItemCollection.AddRange Method

Adds the items in an array of ListItem objects to the collection.

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

public:
void AddRange (
	array<ListItem^>^ items
)
public void AddRange (
	ListItem[] items
)
public function AddRange (
	items : ListItem[]
)

Parameters

items

An array of ListItem objects that contain the items to add to the collection.

Use the AddRange method to add the items in the array of ListItem objects specified by the items parameter. This allows you to add multiple ListItem objects to the collection in a single step.

No code example is currently available or this language may not be supported.
ListItemCollection myListItemCollection = new ListItemCollection();
// Creates an array of ListItems that are used to populate
// the collection.    
System.Web.UI.WebControls.ListItem newListItemArray[] = 
    new ListItem[tempDataTable.get_Count()];
// Populates the array of ListItems with generic data.
for (int i = 0; i < tempDataTable.get_Count(); i++) {
    newListItemArray.set_Item(i, new ListItem());
    newListItemArray[i].set_Text("Item " + Convert.ToString(i));
    newListItemArray[i].set_Text("Item " + Convert.ToString(i));
    newListItemArray[i].set_Value(Convert.ToString(i));
}
// Adds an entire array of ListItem objects to the collection.
myListItemCollection.AddRange(newListItemArray);

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: