displaying image on datagrid

Posted on 2011-10-13
Last Modified: 2012-05-12
this gives error saying Cannot implicitly convert type 'int' to 'bool'

because my data field for attachment is int and I guess I am trying to use as bool.. but how can I fix that that if my int attachment comes back from database as null value, it wouldnt show the image... thats all I want.. if has int value... that time I want to see image....since I will need the value of the attachment as a int also need to grab the id also while doing this for images display true and false.. maybe need to use something other than GridTemplateColumn?

<telerik:GridTemplateColumn UniqueName="attachment">
                            <HeaderStyle Width="30px" />
                                <asp:Image runat="server" ID="imgAttachment" Visible='<% #Eval("attachment") %>'
                                    ImageUrl="../images/attachment.jpg" AlternateText="attachment"/>
                                <asp:Label ID="Label1" runat="server" Text='<%# (int)Eval("attachment") ? "NULL" : "&nbsp;" %>'></asp:Label>
Question by:1jaws
    LVL 51

    Accepted Solution

    on item created event, check the data values and set the visibility of image

    Author Closing Comment

    thank you so much...
    LVL 51

    Expert Comment

    also you can just use "" instead of "&nbsp;"

    when do you get null for id? if you try to set visibility of row all together you can put all items in a server side div...


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    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…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    745 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