Hello There I'm trying to set the visibility of button in list view item template based on the session object and databound property

<asp:Button ID="deleteCommentButton" runat="server" Text="Delete Comment"
            CssClass="redButton" 
            ToolTip="<%# Session[1].ToString() %>" 
            Visible="<%# Session[1].ToString() == Bind("fullname") ? true : false %>"
            style="float:right; margin-left:5px; margin-top:-25px;"
            onclick="deleteCommentButton_Click" />

But I'm getting errors . . Any suggestions?

有帮助吗?

解决方案

Please try this

<asp:Button ID="deleteCommentButton" runat="server" Text="Delete Comment"
        CssClass="redButton" 
        ToolTip='<%# HttpContext.Current.Session[1].ToString() %>' 
        Visible='<%# HttpContext.Current.Session[1].ToString() == Bind("fullname") ? true : false %>'
        style="float:right; margin-left:5px; margin-top:-25px;"
        onclick="deleteCommentButton_Click" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top