SPFieldUrl - doesn't always appear
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();
You may be getting an exception, for example if
listItem["Title"]
is Null, Then
listItem["Title"].ToString()
Will throw a nulll reference exception
精彩评论