Asp.网络绑定和会话条件逻辑



你好,我正试图根据会话对象和数据绑定属性设置列表视图项模板中按钮的可见性

<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" />

但是我得到错误。有什么建议吗?

请尝试一下

<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" />

最新更新