View Single Post
  #1 (permalink)  
Old November 21st, 2007, 12:31 PM
Aaron Edwards Aaron Edwards is offline
Friend of Wrox
 
Join Date: Apr 2004
Location: San Francisco, CA, USA.
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default Databinding the ImageURL Prop of an Image Control

I've got a TemplateField in a GridView that holds an ASP Image control, and populates it using databinding syntax as follows:

<asp:TemplateField>
    <EditItemTemplate>
        <asp:Image runat="server" ID="imgImage" Width="80" ImageUrl='<%# DataBinder.Eval ( Container, "DataItem.txtImageName","Images/Store/{0}" ) %>' />
        <div align="center">
            <asp:LinkButton runat="server" ID="lbSelectImage" Text="Select Image" OnClick="btnSelectImage_Click"></asp:LinkButton>
        </div>
    </EditItemTemplate>
    <ItemStyle Width="100px" HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
        <asp:Image runat="server" ID="imgImage" Width="80" ImageUrl='<%# DataBinder.Eval ( Container, "DataItem.txtImageName","Images/Store/{0}" ) %>' />
    </ItemTemplate>
</asp:TemplateField>

For some reason, intermitently, the images all come out blank, and looking at the source shows that all the images' src attributes are set to "", as in src="". This seems to happen when I open this page as a popup from another page.

Thanks in advance for your help. This one is really weird.

Aaron