Asp.Net数据绑定和会话条件逻辑

时间:2011-10-23 20:24:40

标签: asp.net session listview databound databound-controls

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

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

但我收到了错误。 。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

请试试这个

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