List items belonging to lists can be deleted in two different ways:
- DeleteListItem(Guid id) - Delete a list item by passing its ID to the DeleteListItem method
- DeleteListItem(IListItem item) - Delete a list item by passing the actual item we want to delete to the DeleteListItem method
Delete a list item by passing its ID to the DeleteListItem method:
| DeleteListItem(Guid id) |
Copy Code |
|
// create a new instance of ListManager Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager(); // delete the second item from the first
list IList allLists = listManager.GetLists();
if(allLists.Count > 0)
{
// get reference to the first list
Telerik.Lists.INamedList firstList = (Telerik.Lists.INamedList)allLists[0];
if(firstList.Items.Count > 2)
{
// get reference to the second list item of the first list
Telerik.Lists.IListItem secondItem =
(Telerik.Lists.IListItem)firstList.Items[1];
Guid secondItemId = secondItem.ID;
// finally, delete the second item of the first list
listManager.DeleteListItem(secondItemId);
}
}
|
Delete a list item by passing the actual item we want to delete to the DeleteListItem method:
| DeleteListItem(IListItem item) |
Copy Code |
|
// create a new instance of ListManager Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager(); // we are going to delete the second item from the first
list IList allLists = listManager.GetLists(); if (allLists.Count
> 0)
{
// get reference to the first list
Telerik.Lists.INamedList firstList = (Telerik.Lists.INamedList)allLists[0];
if (firstList.Items.Count > 2)
{
// get reference to the second list item of the first list
Telerik.Lists.IListItem secondItem =
(Telerik.Lists.IListItem)firstList.Items[1];
// finally, delete the second item of the first list
// notice that we are passing the actual IListItem object to be deleted
listManager.DeleteListItem(secondItem);
}
}
|
See Also