Populate / Set or Get Data / Value from / to Hyperlink Column

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”;

MyURL.Url = http://www.google.com;

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; 

Advertisements

3 Comments »

  1. Farah said

    I am not very familiar with SharePoint. Where do I add this code? Which page?

    Thank you

  2. farhanfaiz said

    Mostly, you can write this code behind an event handler. If you don’t have much idea about the event handlers, do vivst the following link, it may help you.

    https://farhanfaiz.wordpress.com/2007/12/31/creating-adding-an-event-handler

    do let me konw in case you require further assistance.

    regards,
    farhan

  3. Anonymous said

    SPFieldUrlValue MyURL = new SPFieldUrlValue();
    MyURL.Description = “Google”;
    MyURL.Url = http://www.google.com;
    Item[“HyperLinkColumnName”] = MyURL;

    This code snippet helped.
    Thanks alot!! 🙂 Great Post!!

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: