Sitefinity CMS

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

Glossary Item Box

There are two methods for creating a new NamedList object:

 

 Create new empty list object:

CreateList() Copy Code
// creates new empty list
Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager();
Telerik.Lists.INamedList newList = listManager.CreateList();
// attention! When a new list is created it is not yet saved to a database
// this is convenient place to set some initial list properties
newList.Name = "My list";
// note that properties such as ID, DateCreated and Owner are automatically
// set by Sitefinity. This however does not mean that you cannot
// change them
newList.Created = DateTime.Now.AddDays(-1); // let's pretend we have created list yesterday
// finally we can save the list to the database
listManager.SaveList(newList);  

 

Create new list with name of the list passed as an argument:

CreateList(string name) Copy Code
// creates new empty list
Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager();
Telerik.Lists.INamedList newList = listManager.CreateList(
"My list");
// finally we can save the list to the database
listManager.SaveList(newList);

 

See Also