P
Parrot
I cannot get an image to display in a column of my GridView control. I build
the fields at run time and create a table containing my data and then bind it
to the Gridview. My cod e is shown below:
DataTable dt = dataSet1.Tables.Add("Imagetable");
dt.Columns.Add(new DataColumn("File path", typeof(string)));
dt.Columns.Add(new DataColumn("Image file",
typeof(System.Web.UI.WebControls.Image)));
// this is a loop
{
DataRow dr = dataSet1.Tables["Imagetable"].NewRow();
dr[0] = name.ToString();
System.Web.UI.WebControls.Image image = new
System.Web.UI.WebControls.Image();
image.ImageUrl = dirpath + name;
image.Height = 50;
image.Visible = true;
dr[1] = image;
dataSet1.Tables["Imagetable"].Rows.A dd(dr);
}
DataView v = new DataView(dt);
GridView1.DataSource = v;
GridView1.DataBind();
My first column displays ok but the second column which is the image column
does not even display a column at all or even the heading. Does anyone know
what the problem is?
the fields at run time and create a table containing my data and then bind it
to the Gridview. My cod e is shown below:
DataTable dt = dataSet1.Tables.Add("Imagetable");
dt.Columns.Add(new DataColumn("File path", typeof(string)));
dt.Columns.Add(new DataColumn("Image file",
typeof(System.Web.UI.WebControls.Image)));
// this is a loop
{
DataRow dr = dataSet1.Tables["Imagetable"].NewRow();
dr[0] = name.ToString();
System.Web.UI.WebControls.Image image = new
System.Web.UI.WebControls.Image();
image.ImageUrl = dirpath + name;
image.Height = 50;
image.Visible = true;
dr[1] = image;
dataSet1.Tables["Imagetable"].Rows.A dd(dr);
}
DataView v = new DataView(dt);
GridView1.DataSource = v;
GridView1.DataBind();
My first column displays ok but the second column which is the image column
does not even display a column at all or even the heading. Does anyone know
what the problem is?