asp.net - 根据条件在aspx页面中隐藏项目模板

标签 asp.net aspxgridview

我的 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>&nbsp;</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>&nbsp;</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/

相关文章:

asp.net - 在 ASPxGridView 中获取 CheckBox.Checked 无法正常工作

c# - 当从代码后面单击按钮时,检查 Dataitemtemplate devexpress gridview 中的复选框状态

asp.net - 更改 GridView 中特定记录的样式

c# - 如何通过编程方式将货币格式添加到 AspxPivotGrid 中的数据行?

javascript - JS函数在onclick事件中不可见

c# - 将哈希表中的所有键检索到字符串中

c# - 如何找出 Application_End 在 Azure 应用服务上触发的原因

c# - NUnit 以编程方式设置测试名称

c# - 基于域和主机名的 ASP.NET MVC 路由

asp.net - 如何以编程方式选择 ASpxGridView 中 ASPxComboBox 中的值