I have a GridView that shows information from a building. I am loading the information into the GridView from a database like this:
var buildings = (from t in dc.Towns
where (t.userid == userid) && (t.time < DateTime.Now)
join b in dc.Buildings
on t.buildingid equals b.buildingid
into j1
from j2 in j1.DefaultIfEmpty()
group j2 by j2.buildingname
into grouped
select new
{
Building= grouped.Key,
Picture= grouped.First().imagePath,
Number= grouped.Count()
});
gvBuildings.DataSource = buildings.ToList();
gvBuildings.DataBind();
But I can’t display the image, it only shows the path where its saved. How can I display the image from the path in the GridView?
You have to have column type that can display image, use Image Field and set DataImageUrlField property with that URL, look here for details:
http://msdn.microsoft.com/en-us/library/aa479350.aspx