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 />
So, this is the label inside a “ListView1” i need what Eval finds during each iteration of pumping out of the attached database.
<% 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" />
<% }%>
and this is my attempt at retrieving the label.Text. i know it is something similar to this but i might be doing it wrong… well i am doing it wrong.
Thanks you very much for any information you can provide as i have just spent about 10 hours changing the ways i could achieve this result.
I would do something like:
on each of the
Buttoncontrols.