0

I have the following in a datagrid using .NET 2:

<asp:HyperLink runat="server" NavigateUrl='<%# "edit.aspx?f=" & DataBinder.Eval(Container.DataItem, "forum_id") & "&t=" & DataBinder.Eval(Container.DataItem, "thread_id") & "&p=" & DataBinder.Eval(Container.DataItem, "post_id") %>' Text="Edit" ID="Hyperlink1"></asp:HyperLink>

At the moment, this link appears in all posts (or datagrid rows) in a simplistic forum I coded years ago.

I can detect the user using the forum with the following code:

Request.ServerVariables("LOGON_USER")

How do I show/hide the hyperlink on each post based on the servervariable?

So if I have 10 posts in a particular page, where 3 of those posts are by user x, how do I only show that hyperlink when user x is viewing that page, only on the posts which user x created?

oshirowanen
  • 15,297
  • 82
  • 198
  • 350
  • 1
    Are you sure Request.ServerVariables("LOGON_USER") is what you need ? From MSDN : LOGON_USER : The Windows account that the user is impersonating while connected to your Web server. Use REMOTE_USER, UNMAPPED_REMOTE_USER, or AUTH_USER to view the raw user name that is contained in the request header. The only time LOGON_USER holds a different value than these other variables is if you have an authentication filter installed. – sm_ Aug 22 '14 at 14:44

1 Answers1

1

try adding visible attribute with the following code :

<asp:HyperLink visible='<%# Request.ServerVariables("LOGON_USER") == "x" %>' runat="server" NavigateUrl='<%# "edit.aspx?f=" & DataBinder.Eval(Container.DataItem, "forum_id") & "&t=" & DataBinder.Eval(Container.DataItem, "thread_id") & "&p=" & DataBinder.Eval(Container.DataItem, "post_id") %>' Text="Edit" ID="Hyperlink1"></asp:HyperLink>
sm_
  • 2,572
  • 2
  • 17
  • 34