Question

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?

Was it helpful?

Solution

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" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top