p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Databinding the ImageURL Prop of an Image Control (http://p2p.wrox.com/showthread.php?t=63966)

Aaron Edwards November 21st, 2007 12:31 PM

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



Aaron Edwards November 22nd, 2007 12:53 PM

Nevermind. The values in the database were actually null. I can't believe I didn't check that (they're not supposed to be). Just goes to show you, if there is a way for users to enter incomplete data, they always will.

Thanks.

Aaron



All times are GMT -4. The time now is 06:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.