Link to home
Start Free TrialLog in
Avatar of 1jaws
1jawsFlag for United States of America

asked on

displaying image on datagrid

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" />
                            <ItemTemplate>
                                <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>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1jaws

ASKER

thank you so much...
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...