4

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?

6

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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