Sitefinity CMS

Modifying List Items Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Modules API > Lists > List Items > Modifying List Items

Glossary Item Box

Updating a ListItem is a very simple process:

  1. Get a ListItem associated with a transaction
  2. Change its properties
  3. Save the ListItem with ListManager

 

SaveListItem(IListItem item) Copy Code
// create a new instance of ListManager
Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager();
// update 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;
       
// in order to have ListItem associated with a transaction, we need to retrieve
       
// ListItem through GetListItem function of ListManager
       
Telerik.Lists.IListItem modifyItem = listManager.GetListItem(secondItemId);
       
// modify the properties of the ListItem
       
modifyItem.Headline = "This is a changed headline";
       
// and finally save it with ListManager
       
listManager.SaveListItem(modifyItem);
   }
}

 

 

See Also