2011-10-05 52 views

回答

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

其中FormatText可以在后面的代码的方法:

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

我在if语句中得到以下错误'int.Parse(String,System.IFormatProvider)的最佳重载方法匹配有一些无效参数。 – BumbleBee

1

试试这个:

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