English 中文(简体)
2. 对比“用户Name”
原标题:Getting runtime Eval() label to compare to Session["userName"]

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个小时的时间来改变实现这一结果的途径。

最佳回答

我想做的是:

Visible= <%# Session["userName"].ToString() == Eval("UserName").ToString() %> 

<代码>Button控制。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签