Thanks for links but the gridview was not as flexible as i thought so i used a datalist instead. and i have the images loading perfect. see code below:
public void populateImages(string siteid, long auditid)
{
DataSet localds = new DataSet();
try
{
localds.Clear();
DBCON dbcon = new DBCON("masterConnectionString");
if (dbcon.startup() == false)
{
VARERR.Visible = true;
VARERR.Text = "Your connection to the database has failed, please refresh the page and try again.";
}
else
{
localsqlconnect = dbcon.getConection();
string queryname = "select * from SitePhotos where SiteId = '" + siteid + "' and AuditPeriodId = " + auditid;
// string queryname = "select * from SitePhotos where AuditPeriodId = " + auditid + " and SiteId like " + siteid;
localsqlDapt = new SqlDataAdapter(queryname, localsqlconnect);
//localsqlDapt.SelectCommand.Parameters.Add("@siteid", SqlDbType.NVarChar).Value = siteid;
//localsqlDapt.SelectCommand.Parameters.Add("@auditid", SqlDbType.BigInt).Value = auditid;
localsqlDapt.Fill(localds, "PhotoData");
int rowcount = localds.Tables["PhotoData"].Rows.Count;
if (rowcount <= 0)
{
VARERR.Visible = true;
VARERR.Text = "Unable to locate site photos for your selection.";
}
else {
for (int i = 0; i <= rowcount - 1; i++)
{
String fpath = localds.Tables["PhotoData"].Rows[i][4].ToString();
String fullpath = Server.MapPath(fpath);
if (!File.Exists(fullpath)) {
//remove item
localds.Tables["PhotoData"].Rows.RemoveAt(i);
}
}
DataList1.DataSource = localds;
DataList1.DataBind();
txtsiteidVAR.Text = "";
ddlsiteidsVAR.SelectedIndex = 0;
}
localsqlconnect.Close();
dbcon.CloseConnection();
}
}
catch (Exception ex)
{
VARERR.Visible = true;
VARERR.Text = "Unable to locate site photos for your selection.";
}
}
The challenges still outstanding is having the image viewed larger onclick by the users