Asp.Net Databound and Sessions Conditional Logic
-
11-02-2021 - |
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?
La 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" />
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow