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.Count];

// Populates the array of ListItems with generic data.
for (int i=0; i < tempDataTable.Count; i++) {
    newListItemArray[i] = new ListItem();
    newListItemArray[i].Text = "Item " + i.ToString();
    newListItemArray[i].Value = i.ToString();
}

// Adds an entire array of ListItem objects to the collection.
myListItemCollection.AddRange(newListItemArray);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2021-10-07
  • 2022-12-23
  • 2021-07-09
相关资源
相似解决方案