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;


1 Answer 1


Tested the snippet below in Visual Studio:

            var ctx = new ClientContext(siteUrl);
            List olist = ctx.Web.Lists.GetByTitle("MyList22");
            ListItemCreationInformation creationItem = new ListItemCreationInformation();
            ListItem lstItem = olist.AddItem(creationItem);
            var teststring = "";
            lstItem["Title"] = string.IsNullOrEmpty(teststring) || string.IsNullOrWhiteSpace(teststring) ? "Title not specified" : "Test"; 

The Title field was set to "Title not specified" without problem:

enter image description here enter image description here

  • Thanks for the response @Jerry_MSFT. At code level, I also get the value of Title when debugging but it seems it gets cleared out after either lstItem.Update() or ctx.ExecuteQuery() is called. Commented Jan 20, 2020 at 9:57
  • Also, if I only assign the Title value the title is not emptied. If I set Title and an additional field/s, only the last field that I set is not emptied Commented Jan 20, 2020 at 10:01
  • @ThobanjaloShangase, if Title field can be set with a assigned value, it shoulen't be a issue to update with another field. I suggest you could create a new empty list in SharePoint to see if you can reproduce the issue.
    – Jerry
    Commented Jan 20, 2020 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.