SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the Object Model and the Microsoft.SharePoint.Publishing.Fields.LinkFieldValue namespace in an attempt to set the value of a Hyperlink Column on a SharePoint 2007 Publishing Site.

However, if the field has no value prior to my update, I get System.ArgumentNullException when I attempt the assignment.

using Pub = Microsoft.SharePoint.Publishing;

int id = 1;
SPListItem item = SPContext.Current.List.GetItemById(itemId);
    Pub.Fields.LinkFieldValue destination = 
        new Pub.Fields.LinkFieldValue("<a href=\"\">Link</a>");
    item["MyHyperlink"] = destination; //Null Exception here for item["MyHyperlink"]
share|improve this question
up vote 0 down vote accepted

Sorry to post a link, but did you check out this example:

share|improve this answer
Thanks. - My error was more along the lines that I was using a different column type than I had thought. Your link worked once I created a site column using the type "Hyperlink with formatting and constraints for publishing" the code above worked. I was getting the null error because the site column was actually the "Hyperlink or Picture" column it just expected a string with the URL and Display Text comma delimited – W4keDotNet Oct 24 '11 at 13:37

Your Answer


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.