【发布时间】:2014-07-18 14:16:25
【问题描述】:
在我的代码中,我正在检索管理员或用户的用户。在我的 aspx 表上,如果用户不是管理员,我想隐藏/删除一个“th”标签。
这是我的html代码:
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<asp:Label ID="lblActionHeader" runat="server" Visible = '<%# UserIsAdmin() %>' >
<th>Action</th>
</asp:Label>
<th>Name of Insured</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptrList" runat="server" OnItemCommand="rptrList_ItemCommand">
<ItemTemplate>
<tr>
<asp:Label ID="lblActionBody" runat="server" Visible = '<%# UserIsAdmin() %>' >
<td>
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandName="Edit">
</asp:LinkButton>
</td>
</asp:Label>
<td>
<asp:TextBox ID="lblName" runat="server" Text='<%# Bind("name") %>' Enabled="false" CssClass="m-wrap small"></asp:TextBox>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
在我的代码中 - 在我的代码后面,我有这个功能可以获取用户是否是管理员。
public bool UserIsAdmin()
{
bool bRet;
bool.TryParse(Session["isAdmin"].ToString(), out bRet);
return bRet;
}
在中继器上它可以工作,但在标题上它不工作。
有没有其他方法可以隐藏标签
【问题讨论】:
-
我从这个链接stackoverflow.com/questions/4949467/…得到了答案
-
那么请添加您的答案并打勾。
标签: html asp.net html-table