我的 ListView 中有以下项目模板
<ItemTemplate>
<asp:LinkButton ID="ibtnEdit" runat="server" Height="20px" Width="20px" ToolTip="Edit this Category" CommandArgument='<%# Eval("Category_ID") %>' CommandName="EditObject" CausesValidation="False"> <i class="glyphicon glyphicon-edit"></i> </asp:LinkButton>
</ItemTemplate>
我想根据以下条件隐藏此列。此状态字段包含 1 或 0。
<%# Bind("Status") %>
我不知道该怎么做
最佳答案
我试过下面的代码,它有效
<asp:LinkButton ID="ibtnEdit" runat="server" Height="20px" Width="20px" ToolTip="Edit this Category"
CommandArgument='<%# Eval("Category_ID") %>' Visible='<%# DecideHere((int)Eval("Status")) %>' CommandName="EditObject"
CausesValidation="False"> <i class="glyphicon glyphicon-edit"></i> </asp:LinkButton>
在代码后面
protected bool DecideHere(int id)
{
if (id == 1 )
return true;
else
return false;
}
关于asp.net - 根据条件在aspx页面中隐藏项目模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43436645/