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>
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>