I needed to get the value of a SharePoint hyperlink field in a custom list the other day so I simply tried to access the value of the field directly in the object model:
[code lang="csharp"]SPListItem item = list.GetItemById(1);</span>
string URL = item[“URL”].ToString();[/code]
The only problem with this is whilst it gets the value, you end up with two URL’s separated by a comma. This is because one is the actual display text for the field and the other is the value (the actual URL itself).
In order to get just the URL value, you need to use the following object model code:
[code lang="csharp"]SPFieldUrlValue value = new SPFieldUrlValue(item[“URL”].ToString());
string URL = value.Url;[/code]
You can also use value.Description to get the actual display text for the field.
Simples! Hope this helps