Display particular word on some condition Eval Asp.net

故事扮演 提交于 2019-12-11 09:27:13

问题


<asp:Label ID="lblLeaveStatus" runat="server" Font-Bold="true" Text='<%# Eval("Leave_Status").ToString() == 'A' ? 'Approved' : 'Applied' %>'></asp:Label>

Condition to display a particular word in the GridView on some condition

Could some thing like this work on Gridview

I get an error Server Tag not well formed


回答1:


Try this

<asp:Label ID="lblLeaveStatus" runat="server" Font-Bold="true" Text='<%# Eval("Leave_Status").ToString() .Equals ( "A") ? "Approved" : "Applied" %>'></asp:Label>



回答2:


Use Below Code:

<% if(Eval("Leave_Status").ToString() == "A"{%>

<asp:Label ID="lblLeaveStatus" runat="server" Font-Bold="true" Text="Approved"></asp:Label>

<%}
else {
%>
<asp:Label ID="lblLeaveStatus" runat="server" Font-Bold="true" Text="Applied"></asp:Label>

<%}%>


来源:https://stackoverflow.com/questions/15425833/display-particular-word-on-some-condition-eval-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!