Im trying to write some code in c# to add parent and child items to a custom
list. I have the code successfully creating folder/parent level items but
how do I add child items to the parent items?
The list basically is a store for two levels of menu items. Can anyone
assist or point me in the right direction?
Here is the code to add the parent folder:
using (SPSite site = new SPSite(string.Concat(rootSitePath, "/",
webSitePath)))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[listGuid];
SPListItemCollection listItems = list.Items;
foreach (MenuItem menuItem in menu.Items)
{
SPListItem listItem = list.Folders.Add();
listItem["MenuItemDisplayText"] =
menuItem.displayName;
listItem["MenuItemUrl"] = menuItem.url;
listItem["MenuItemHint"] = menuItem.hint;
listItem.Update();
//add a child to the above list item
}
}
}