Friday, January 13, 2012

Updating hyperlink fields programmatically

Data in the Hyperlink Column can be populated / set in the following manners: 
Item[“HyperLinkColumnName”] = “http://www.google.com, Google”;
Item.Update(); 
Don’t forget space after comma. 
Or 
SPFieldUrlValue MyURL = new SPFieldUrlValue();
MyURL.Description = “Google”;
Item[“HyperLinkColumnName”] = MyURL;  

Data from the Hyperlink Column can be get in the following manner: 
SPFieldUrlValue MyURL = new SPFieldUrlValue(Item[“HyperLinkColumnName”].ToString()); 
string URLText = MyURL.Description;
string URL = MyURL.Url; 

No comments:

Post a Comment