I have an SPListItem. I have a field on the item of type SPFieldMultiLineText. How can update the value of that field?


You need to return the field value in HTML/Plain text format and update it. Here you go:

SPSite site = new SPSite("http://site")) 
         using (SPWeb web = site.OpenWeb()) 

           SPList list = web.Lists["YourList"]; 
           SPListItem item= list.GetItemById(1);
           SPFieldMultiLineText multilineField = item.Fields.GetField("YourColumn") as SPFieldMultiLineText;
           // Get the field value as HTML
           string htmltext= multilineField.GetFieldValueAsHtml(item["YourColumn"], item);

           //or Get the field as Text
           string normaltext= multilineField.GetFieldValueAsText(item["YourColumn"]); 

           //updating html field text
           htmltext+= "Hello I am being updated!";
           item["YourColumn"] = htmltext;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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