Can't bind image column in datagrid

J

Jim Hammond

The code below implements two datagrid columns that display images. The
first column is just a test that always displays the same image directly
from a file. The second column pulls the image from the dataset. The
datagrid contains several additional columns that are not seen here because
they are automatically generated and bound to the dataset. All columns work
except the second image column, which attempts to bind to the dataset.

When the same image is pulled from the database, the datagrid just displays
a little box with a red X in it. Note that when the row in the DB contains a
NULL for the image, the datagrid displays the same little
(square-circle-triangle) placeholder icon
as it does in the designer.

Thanks,

Jim


<Columns>
<asp:TemplateColumn HeaderText="Photo from File">
<ItemTemplate>
<img runat="server" src='<%# "c:\\Pic001.jpg"%>' ID="Img1"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Photo">
<ItemTemplate>
<asp:Image ImageUrl= '<%#DataBinder.Eval(Container.DataItem,
"UserImage")%>' runat=server ID="Image1"/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
 
J

Jim Hammond

Sorry, the problem is that I am giving the template column the name of a
database image column, but it is expecting the path to an image file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top