If the
imagepath
column contains the
name of a file inside the
images
directory, then it should be as simple as:
Image1.ImageUrl = "~/images/" + Convert.ToString(dr["imagepath"]);
If the column contains the
physical path of the file on the server, then it gets more complicated. Assuming everything is within the same physical folder structure, you might be able to use something like this:
string physicalPath = Convert.ToString(dr["imagepath"]);
string imagesPhysicalPath = Server.MapPath("~/images/");
if (physicalPath.StartsWith(imagesPhyisicalPath, StringComparison.OrdinalIgnoreCase))
{
string relativePath = physicalPath.Substring(imagesPhysicalPath.Length);
image.ImageUrl = "~/images/" + relativePath.Replace('\\', '/');
}