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 this list with artists that I manipulate with C#. I can get all te values of the list with this code part and change

SPListItem listItem = properties.ListItem;
SPWeb artistWeb = properties.Web;
string artist = listItem["Artiest"] as string;
string adres = listItem["Adres"] as string;
string postcode = listItem["Postcode"] as string;
string woonplaats = listItem["Woonplaats"] as string;
string land = listItem["Land"] as string;
string prijs = listItem["Prijs"] as string;
string rekeningnummer = listItem["Rekeningnummer"] as string;
string email = listItem["E-Mail"] as string;


string relURL = artistWeb.ServerRelativeUrl + (artistWeb.ServerRelativeUrl.EndsWith("/") ? String.Empty : "/") + artist;
relURL = relURL.Substring(1, relURL.Length - 1);
string FullURL = artistWeb.Site.MakeFullUrl(relURL);


listItem["URL"] = FullURL;
listItem.Update();

So I want to set the URL description just like the last part "listItem["URL"] = FullURL;"
Is this possible?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You have to use SPFieldUrlValue. Here is an example:

string FullURL = artistWeb.Site.MakeFullUrl(relURL);
SPFieldUrlValue UrlValue = new SPFieldUrlValue();
UrlValue.Description = "Put desciption here";
UrlValue.Url = FullUrl;

listItem["URL"] = UrlValue;
listItem.Update();
share|improve this answer
    
Thank you, that solved my problem! –  Fabian Blom Feb 7 '13 at 8:47

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.