Sitefinity CMS

Deleting Lists Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Modules API > Lists > Lists (NamedList) > Deleting Lists

Glossary Item Box

Lists can be deleted in two different ways. One is to pass the ID of the list to the DeleteList method, while another way is to pass the list object itself to the DeleteList method.

By deleting the list, list items belonging to this list will be deleted as well.

 

Delete a list by passing the ID of the list to the DeleteList method:

DeleteList(Guid id) Copy Code
// create a new instance of ListManager
Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager();
      
// get all lists and delete the first one
IList lists = listManager.GetLists();
if (lists.Count > 0)
{
   Telerik.Lists.INamedList firstList = (Telerik.Lists.INamedList)lists[0];
   
// one option is to delete a list by passing the list ID to the DeleteList method
   
listManager.DeleteList(firstList.ID);
}

 

Delete a list by passing the list object itself to the DeleteList method:

DeleteList(INamedList list) Copy Code
// create a new instance of ListManager
Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager();
// get all lists and delete the first one
IList lists = listManager.GetLists();
if (lists.Count > 0)
{
   Telerik.Lists.INamedList firstList = (Telerik.Lists.INamedList)lists[0];
   
// another option- delete a list by passing the list itself to the DeleteList method
   
listManager.DeleteList(firstList);
}


See Also