我的中继器中有一个 DIV,如下所示:
<asp:Repeater ID="topicView" runat="server" OnItemCommand="Delete_ItemCommand">
<ItemTemplate>
<table width="945px" cellpadding="0" cellspacing="0" border="0" class="post-table">
<tr>
<td colspan="2">
<div class="post-info">
<div class="post-info-left"><%#DataBinder.Eval(Container.DataItem, "PostDate")%></div>
<div class="post-info-right">#<%#DataBinder.Eval(Container.DataItem, "PostID")%></div>
<div class="clear"></div>
</div>
</td>
</tr>
<tr>
<td class="post-left">
<p><strong><%#DataBinder.Eval(Container.DataItem, "Username")%></strong></p>
</td>
<td class="post-right">
<p><%#DataBinder.Eval(Container.DataItem, "PostBody")%></p>
</td>
</tr>
<tr>
<td colspan="2">
<div class="post-edit">
<p id="postEditAdmin" runat="server" visible="false"><a class="fancybox.iframe fancybox" href='editpost.aspx?postID=<%#DataBinder.Eval(Container.DataItem, "PostID")%>'>Edit</a> | <asp:LinkButton ID="deleteBtn" runat="server" Text="Delete" CommandName="Delete" OnClientClick="javascript:if(!confirm('Delete this information? this will delete permanently'))return false;" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "PostID")%>' /></p>
<p id="postEdit" runat="server" visible="true"><i>You must be an admin to be able to edit or delete a post</i></p>
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
谁能让我知道如何将 postEditAdmin.Visible 设置为 true 并将 postEdit.Visible 设置为 false?它没有在页面加载中被拾取。
另请注意,它将根据 if 语句进行更改。这是我到目前为止所拥有的:
if (Session["role"].ToString() == "2")
{
postEditAdmin.Visible = true;
postEdit.Visible = false;
}