datagrid template column binding mystery

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 wit ha red X in it. Note that when the row in the DB contains a
NULL for the image, the datagrid displays the same little 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>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top