Problem displaying image (binding image) to ImageColumn in datagrid.

Posted on 2006-05-04
Last Modified: 2011-09-20
Hi there..

Based on a value from my SQLQuery i'm trying to display an image instead of the value in my DataGrid.
The special thing is that i cannot display the value itself inside the grid (due to securityreasons), but i need to use this value to loop through and decide which image (on or off image) should be displayed.

If i hard-code the imageURL like this :
ImageUrl="img\offline24.gif"      it works like a dream..

But.. when i do like this :

ImageUrl='img\<%#Bind("Image") %>'       the image doesn't display, and when looking at properties on the image it shows the <%# Bind("Image") %> as pure text..

So what am i doing wrong here ? or.. how can i do this another way ?

See the code :

--------------The TemplateColumn------------------

<asp:TemplateColumn ItemStyle-Width="40px">
        <asp:Image ID="Image2" runat="server" ImageUrl='img\<%#Bind("Image") %>'></asp:Image>

--------------The TemplateColumn------------------

--------------The Code to generate the Item column and choose image------------------

        Dim ds As New DataSet

        Dim c As New DataColumn
        c.ColumnName = "Image"


        Dim r As DataRow

        For Each r In ds.Tables(0).Rows
            If r.Item(2) = "1" Then
                r.Item(4) = "Online24.gif"
                r.Item(4) = "Offline24.gif"
            End If


        Dim dt As DataTable = ds.Tables(0)

        'return a DataView to the DataTable
        Dim dv As DataView = New DataView(dt)
        dv.Sort = SortField
        Ansatt_Update = dv


--------------The Code to generate the Item column and choose image------------------

Question by:Kripos56

    Author Comment

    More info :

    It's .NET 1.x Framework.

    and when using this scentence :

    <asp:Image ID="Image2" runat="server" ImageUrl='<%# String.Concat("img\", Bind("Image")) %>'></asp:Image>

    I'm getting "Bind is not declared"    (same goes with Eval)...

    LVL 96

    Accepted Solution

    Try this:

    DataBinder.Eval(Container.DataItem, "Image")


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now