SharePoint Blog

Leave a comment

How to programmatically Create SPListItem in a SPFolder

Sample Code to Create SPListItem in a SPFolder

SPSite mySite = new SPSite(http://ServerName/sitename);
SPWeb web = mySite.OpenWeb();
SPList list = web.Lists[“ListName”];
SPFolder f = web.GetFolder(http://ServerName/sitename/Lists/ListName/FolderName);
SPListItemCollection itemColl = list.Items;
SPListItem item = itemColl.Add(f.ServerRelativeUrl , SPFileSystemObjectType.File, null);
item[“Title”] = “Added from Code”;


Leave a comment

Add SharePoint List Items with InfoPath web form using SharePoint Object Model

You want to save the data that is entered into an InfoPath form to a SharePoint list, but InfoPath does not allow you to submit data to a SharePoint list.

This is one of the  useful feature of Microsoft SharePoint is its ability to create and maintain lists that users can leverage to store, view, and share items with other users of the SharePoint site. It is often desirable to be able to view these items and to add additional items with an InfoPath form.

You can use SharePoint object model to insert an Item to a SharePoint List.

Note: Users must have proper permissions assigned to them to be able to add items to the SharePoint list.

Continue reading