Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2007, 12:31 PM
Friend of Wrox
 
Join Date: Apr 2004
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


 
Old November 22nd, 2007, 12:53 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Image to Image Control using JavaScript ctranjith General .NET 1 May 28th, 2013 05:43 AM
Eval ImageUrl doesn´t work studioc BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 May 23rd, 2008 05:57 AM
ImageUrl syntax almotions ASP.NET 2.0 Basics 2 January 24th, 2008 03:47 AM
GridView.SelectedIndex Prop SteveP55419 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 October 8th, 2006 09:08 PM





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