简体   繁体   中英

Visibility of a link button on session variable asp c# repeater

Inside a repeater control I have a LinkButton, this LinkButton must only modify data that belongs to the same user that posted it, for this I need to evaluate a session variable and only show the LinkButton on the information that is owned by the signed user.

I've tried several variants of the following structure, yet I've had no success:

<asp:LinkButton ID="lnkocultar_post" runat="server" class="pull-right btn-box-tool" OnCommand="lnkocultar_post_Command" CommandArgument='<%# Eval("post_ID") %>' Visible='<%# bool.Parse(Session["Miembro_Id"] == Eval("Miembro_Id")) ? "true": "false"%>'>

<i class="fa fa-times">

</i>

</asp:LinkButton>

To make the visibility of the control dependant on whether the id's match, you can just bind to a string comparison of the two.

<asp:LinkButton ID="lnkocultar_post" runat="server" class="pull-right btn-box-tool" OnCommand="lnkocultar_post_Command" CommandArgument='<%# Eval("post_ID") %>' Visible='<%# String.Equals(Session["Miembro_Id"], Eval("Miembro_Id"))%>'>
    <i class="fa fa-times"></i>
</asp:LinkButton>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM