0
votes

I have below code to get list items and then I bind that to GridView. List has 2 text columns and a image column. After I bind the datasource to Grid I found Images are not displaying. After debugging I found Image URL return some invalid URLs. Sample returned values for URL:

http://url/Style%20Library/images1.jpg,
http://url/Style%20Library/images2.jpg,
http://url/Style%20Library/images3.jpg,

Images are uploaded to style library and in list image column is Hyperlink or Picture type.

SPListItemCollection collListItems = null;
SPSite site = new SPSite("http://siteURL/");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Lapptop"];
collListItems = list.Items;
return collListItems.GetDataTable();

Any idea?

1

1 Answers

0
votes

hyperlinks have two properties: url and description

if you don't parse the result you will end up with "url, description"

SPFieldUrlValue value = new SPFieldUrlValue(item[“URL”].ToString());

string URL = value.Url;

http://sharepointcoding.wordpress.com/2009/10/12/get-url-value-of-sharepoint-hyperlink-field/