我在数据库中的数据是0和1,但是我在页面中想要显示:0是未完成,1是完成,页面中显示是完成或者为完成:user_build.aspx.cs中
//状态
public string getchange(int build_states)
{
string j = "";
if (build_states == 0)
{
j = "未完成";
}
else
{
j = "完成";
}
return j;
}
user_build.aspx
<%# getchange((int)Eval("build_states"))%> 报错:
“/webroot”应用程序中的服务器错误。
--------------------------------------------------------------------------------指定的转换无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidCastException: 指定的转换无效。源错误:
行 31: line-height: 20px;">
行 32: <%-- if <%# Eval("build_states")%>=0 then string = 未完成--%>
行 33: <%# getchange((int)Eval("build_states"))%> <a href="looksee.aspx"><asp:Label ID="Label1" runat="server" Text="查看"></asp:Label></a>
行 34: </span>
行 35: <br />
源文件: e:\like_road\webroot\users\user_build.aspx 行: 33 堆栈跟踪:
[InvalidCastException: 指定的转换无效。]
//状态
public string getchange(int build_states)
{
string j = "";
if (build_states == 0)
{
j = "未完成";
}
else
{
j = "完成";
}
return j;
}
user_build.aspx
<%# getchange((int)Eval("build_states"))%> 报错:
“/webroot”应用程序中的服务器错误。
--------------------------------------------------------------------------------指定的转换无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidCastException: 指定的转换无效。源错误:
行 31: line-height: 20px;">
行 32: <%-- if <%# Eval("build_states")%>=0 then string = 未完成--%>
行 33: <%# getchange((int)Eval("build_states"))%> <a href="looksee.aspx"><asp:Label ID="Label1" runat="server" Text="查看"></asp:Label></a>
行 34: </span>
行 35: <br />
源文件: e:\like_road\webroot\users\user_build.aspx 行: 33 堆栈跟踪:
[InvalidCastException: 指定的转换无效。]
这样试试!!