Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying *.jpeg pictures in a datagrid control

Status
Not open for further replies.

leassaf

Instructor
May 20, 2001
49
IL
I’m displaying a datagrid on a web form. The grid is bound to a query in an Access 2000 database. One of the fields in that query is a relative path to *.jpeg pictures. Is there a way of displaying the picture in each row for that datagrid? I was thinking of an ItemTemplate in which I would put an Image control but couldn’t see how. Detailed explanations would be greatly appreciated.

Ciao,

Assaf
 
Hi
No Problem
Convert the column to a template column using the property builder and find the bit of HTML that it has generated for this column.

Change the item template to look like this

<asp:Image ImageUrl='<%# databinder.eval(container, &quot;DataItem.Image_Path&quot;) %>' Runat=server></asp:Image>

Then bind the grid in the normal way.

This just worked fine for me, so if you've any questions, post again

Mark Mark [openup]
 
I have a similar problem... but I need to do it from the server side code...Pl. see below for details...

I need to display images in Datagrid Column. I am using the following code.... but it gives problems...Plz. help...

DataGrid dgProds = new DataGrid();
TemplateColumn dgColHidden = new TemplateColumn();

System.Web.UI.WebControls.Image imgNoDisplay = new System.Web.UI.WebControls.Image();

imgNoDisplay.ImageUrl = &quot;../Images/nodisplay.gif&quot;;
dgColHidden.ItemTemplate = new TemplateControl;
dgColHidden.ItemTemplate.InstantiateIn(imgNoDisplay);
**above line gives run time error... because object dgColHidden.ItemTemplate is not instantiated...I don't know, how to instantiate the object of this type*****
dgProds.Columns.Add(dgColHidden);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top