I am working on an ASP.NET 4.5 C # MVC 5 project that integrates with a SharePoint site using Microsoft.Sharepoint.Client. One of the methods must add an SQL record, and then use 2 of the fields in that record, assign them to the Title field (created by default by SharePoint) and the other to a numeric PartnerID field to create an item to add to a SharePoint list.
The SQL portion runs successfully, but when added to SharePoint, the ID is set correctly and the Title value is emptied. This is despite the fact that the value of the Title has the correct size and matches the single line of the text data type. Check out the excerpt below and tell what you might be doing wrong.
List listCPD = apiContext.Web.Lists.GetByTitle("CommunityPartner"); ListItemCreationInformation creationItem = new ListItemCreationInformation(); ListItem lstItem = listCPD.AddItem(creationItem); lstItem("Title") = string.IsNullOrEmpty(cPAModel.CommunityPartner) || string.IsNullOrWhiteSpace(cPAModel.CommunityPartner) ? "Title not specified" : cPAModel.CommunityPartner; //check for empty string to ensure no empty string from user input level lstItem("PartnerID") = cPAModel.CommunityPartnerID; lstItem.Update(); apiContext.ExecuteQuery();