trouble with Image

Posted on 2014-08-11
Last Modified: 2014-08-11
I'm attempting to select an image path from a database and  load it into an asp Image, but the image doesn't show.
<asp:FormView ID="FormView1" runat="server"  DataSourceID="SqlDataSource1" Width="100%" >
            <table style="width: 100%">
                        <asp:Image ID="Image1" runat="server" Width="1000px" ImageUrl='FieldPics/<%# Eval("relPath") %>' />
                        <%--<img src='FieldPics/<%# Eval("relPath") %>' width="1000px" id="Image1" alt="myPic" />--%>
                        <asp:Label ID="Label1" runat="server" Font-Bold="True" Text='<%# Eval("photoBy") %>' Font-Names="Verdana" Font-Size="12px"></asp:Label>
                        <asp:Button ID="btnRotLeft" runat="server" Text="Rotate Left" />
                        <asp:Button ID="btnRotRight" runat="server" Text="Rotate Right" OnClick="btnRotRight_Click" />

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT replace(relPath,'\', '/') as relPath, picDateTime, county, quad, photoBy, photoDesc, fTrackID FROM fieldPics WHERE id = @PhotoID">
            <asp:QueryStringParameter Name="PhotoID" QueryStringField="photoid" Type="Int32" />

Open in new window

If I do this with an html image, it will show...
<img src='FieldPics/<%# Eval("relPath") %>' width="1000px" id="Image1" alt="myPic" />

Open in new window

But I'm trying to rotate the image with ImageMagick and then I can't do this....
protected void btnRotRight_Click(object sender, EventArgs e)
        Image img = (Image)FormView1.FindControl("Image1");
        string imgSrc = img.ImageUrl;
        ClientScript.RegisterStartupScript(this.GetType(), "error", string.Format("alert('{0}');", imgSrc), true);
        string arg = @"convert """ + Server.MapPath(imgSrc) + @""" -rotate 90 """ + Server.MapPath(imgSrc) + @"""";
        displayImg(imgSrc, 5000);

Open in new window

I also can't get a proper ImageUrl into my ImageMagick command.  It tells me I have illegal characters.  When I use window.alert to display the ImageUrl it shows 'FieldPics/<%# Eval("relPath") %>' rather than 'FieldPics/CONWAY/ATKINS/DSCN0220.JPG'
Question by:Nate_LR
    1 Comment

    Accepted Solution

    I figured out that I needed to do this...
    <asp:Image ID="Image1" runat="server" Width="1000px" ImageUrl='<%# Bind("relPath", "FieldPics/{0}") %>' />

    Open in new window

    instead of this...
    <asp:Image ID="Image1" runat="server" Width="1000px" ImageUrl='FieldPics/<%# Eval("relPath") %>' />

    Open in new window


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now