-
Datagrid and Images
Anyone have an easy method for inserting a picture (based on a product number) into a datagrid column. I assume it needs to be a templet with an image control set in the input frame. But can this string be built in a data class and databind it?
gollnick
-
Re: Datagrid and Images
yes, when you insert the asp:Image control to your template click on "Data Bindings", once youve done that choose the column of your class that the file name is associated to. in the box below that is the format string box. that is where you put something like "/images/{0}". that will bind your file name to the {0} part and will show up on the page.
-
Re: Datagrid and Images
Thanks. Do you mean select the ImageUrl .. Then Container and inside that the DataItem .. then in the format .... "/images/{0}" ???
Would you have an example ??
Thanks .. gollnick
-
Re: Datagrid and Images
yes, it would be in the ImageUrl part of the <asp:Image> tag.
it would look something like this:
<asp:Image runat="server" ID="Img1" ImageUrl="<%# Bind("ImageLocation", "/images/{0}") %>">
that would be inside your <itemTemplate> tag for that column of the gridview.