I am working on a ASP.NET 4.5 C# MVC 5 project that integrates with a SharePoint site using Microsoft.Sharepoint.Client. One of the methods must add a SQL record, and thereafter use 2 of that record's fields, assign them to the Title field (created by default by SharePoint) and the other to a numeric PartnerID field to create an item to be added to a SharePoint list.
The SQL portion executes successfully but when adding to SharePoint, the ID is set correctly and the Title value is emptied. This is despite the Title value being the correct size and matching the single line of text data type. Please see the snippet below and advise what I could 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();