displaying image on datagrid

Posted on 2011-10-13
Medium Priority
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
  • 2
LVL 61

Accepted Solution

HainKurt earned 2000 total points
ID: 36965811
on item created event, check the data values and set the visibility of image

Author Closing Comment

ID: 36965813
thank you so much...
LVL 61

Expert Comment

ID: 36965818
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses

749 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