Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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;
           item.Update();
         }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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