开发者

populate lable control inside a gridview based on inline Conditional statement

开发者_开发技巧I am trying to display a plain text in the column(contains a label) of gridview based on a condition. Here is my erroneous code. Please correct.

 <asp:Label ID="lblAsgn" runat="server"   Text= '<%#Eval("StatusId") == 0 ? "NEW" : "OLD" %>' > </asp:Label>

Thanks in advance.

BB


<asp:Label 
    ID="lblAsgn" 
    runat="server"   
    Text='<%# FormatText(Eval("StatusId")) %>' />

where FormatText could be a method in your code behind:

protected string FormatText(object o)
{
    int value;
    if (int.Parse(o as string, out value) && value == 0)
    {
        return "NEW";
    }
    return "OLD";
}


Try this :

 <asp:Label ID="lblAsgn" runat="server"   Text= '<%# Eval("StatusId").Equals(0) ? "NEW" : "OLD" %>' > </asp:Label>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜