Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to know how to check a Boolean value that is empty ( table with no data row).

my code:
<itemtemplate>
    <asp:Image ImageUrl=<%# GetCheckMark((bool)Eval("CanInsert")) %> ID="ImgCanInsert" runat="server" />
</itemtemplate>


when table is empty this function raise error. In code behind I check for true and false and change image url. So how can I check before eval() to know if it is empty I have tried this but no way:

ImageUrl=<%# Eval("CanSee") == null?"0": GetCheckMark(Eval("CanInsert")) %> 

Please help me.
Posted
Updated 20-Apr-12 23:27pm
v3

1 solution

I have change it in this way and now it is running:

ASP.NET
<itemtemplate>
    <asp:image imageurl="<%# String.IsNullOrEmpty(Eval("CanInsert").ToString()) ? "-" : GetCheckMark(Eval("CanInsert").ToString())%>" id="ImgCanInsert" runat="server" xmlns:asp="#unknown" />
</itemtemplate>

also code behind:
C#
protected string GetCheckMark(string checkd)
{
    return checkd == "True" ? "../../../../../ServerFile/Icons/Editor/True.png" : "../../../../../ServerFile/Icons/Editor/False.png";
}


Thanks all
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900