ListItemCollection.AddRange Method
.NET Framework 2.0
Adds the items in an array of ListItem objects to the collection.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
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.
Community Additions
ADD
Show: