I need to get a label during runtime so that i can compare to the Session["userName"] and choose to show buttons after the comparison. I have look around and this seems to be the solution but i ve run onto trouble as i only get null during runtime.
UserName:
<asp:Label ID="UserNameLabel" runat="server" Text= <%# Eval("UserName") %> />
<br />
因此,这是“ListView1”中的标签,即需要从所附数据库中抽取每台蒸气时发现的数值。
<% Label lbl = (Label) ListView1.FindControl("userName");
string userName = lbl.Text;
if (Session["userName"].ToString() == userName)
{%>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<% }%>
这是我试图重新贴上标签。 案文一知道它类似于这一点,但可能这样做是错误的......如果这样做是错误的。
十分感谢你提供的任何信息,因为我刚刚花了约10个小时的时间来改变实现这一结果的途径。