ASP.NET Databinder if-else条件ASP控件
我有一个值为真或假的对象。如果该值为false,我想显示一个asp:Button控件,否则它什么也不显示。这能做到吗? 我想要这样的东西:ASP.NET Databinder if-else条件ASP控件,asp.net,Asp.net,我有一个值为真或假的对象。如果该值为false,我想显示一个asp:Button控件,否则它什么也不显示。这能做到吗? 我想要这样的东西: <%# DataBinder.Eval(Container.DataItem, "FullyPaid").Equals(false) ? "<asp:Button Text=\"Pay Now\"/>" : ""%> 换一种方式试试: <asp:Button ID="btnPayNow" runat="server" Text
<%# DataBinder.Eval(Container.DataItem, "FullyPaid").Equals(false) ? "<asp:Button Text=\"Pay Now\"/>" : ""%>
换一种方式试试:
<asp:Button ID="btnPayNow" runat="server" Text="Pay Now" Visible='<%# DataBinder.Eval(Container.DataItem, "FullyPaid")%>'/>
我的工作方式与此相同,这是我过去使用可视属性的方式:
Visible='<%#(Convert.ToInt32(Eval("pricetype")) == 1) ? true : false%>'
很简单,但您必须确保FullyPaid必须包含true或false
<asp:Button ID="btnPayNow" runat="server" Text="Pay Now"
Visible='<%#Eval("FullyPaid")%>'/>