views:

23

answers:

1

Within my SharePoint list I use a field to hold a url and text, this is not a custom field, but its a standard SharePoint hyperlink field, SPFieldUrl type. When I set the SpFieldUrl Description and Url properties and save it to my list, on rare occations my data is never saved. How does this happen? Below is a sample of my code.

PopulateListItem(listItem,candidate);
listItem.Update();
SPFieldUrlValue newCandidateUrl = new SPFieldUrlValue();
newCandidateUrl.Description = listItem["Title"].ToString() +" ,"+listItem["FirstName"].ToString();
newCandidateUrl.Url = ConfigurationManager.AppSettings["EditUrl"]+"?id="+listItem.ID.ToString();
listItem["FormLink"] = newCandidateUrl;
listItem.Update();
+1  A: 

You may be getting an exception, for example if

listItem["Title"] 

is Null, Then

listItem["Title"].ToString()

Will throw a nulll reference exception

Shiraz Bhaiji

related questions