Hiding a hyperlink in a non-databound datagrid column

Discussion in 'ASP .Net' started by BobRoyAce, Jan 20, 2005.

  1. BobRoyAce

    BobRoyAce Guest

    I am brand new to ASP.NET and am now required to take over maintenance of a
    ..NET/C# web application. On one of the pages I'm working on there is a
    DataGrid which has multiple columns. One of the columns is not databound and
    instead has up to three hyperlinks in it (Edit, Award, and Cancel). A couple
    of the hyperlinks should not be shown in certain cases. Now, mind you, I
    don't know if it's being done in the way that's best to do it. It looks like
    there is a "panel" being created to contain the hyperlinks that may not be
    visible. I don't know why though (i.e. why not just set hyperlink's Visible
    property and be done with it without a panel?). That being said, I want to
    change the page so that one of the hyperlinks does not show (i.e. Visible =
    False) based on a certain value for a session cookie. It's the Award link in
    the code shown below from the .aspx file in question.

    --- CODE BEGINS ---

    <asp:TemplateColumn HeaderText="Actions">
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <asp:HyperLink id="hlEdit" runat="server" NavigateUrl='<%#
    "Edit.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") %>'
    CssClass="link-text"> <!--onMouseOver='<%# "javascript:toolTip(\"" +
    DataBinder.Eval(Container, "DataItem.PersonToolTip") + "\");" %>'
    onMouseOut="javascript:toolTip();">-->
    Edit
    </asp:HyperLink>
    <asp:panel ID="Panel1" Runat="server" Visible='<%#
    Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'>
    <asp:HyperLink id=hlBids runat="server" Visible='<%#
    Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'
    NavigateUrl='<%# "Award.aspx?id=" + DataBinder.Eval(Container,
    "DataItem.PersonID") %>' CssClass="link-text">
    Award
    </asp:HyperLink>
    </asp:panel>
    <asp:panel ID="panAction" Runat="server" Visible='<%#
    Convert.ToBoolean(DataBinder.Eval(Container,
    "DataItem.PersonStatusCancel"))%>'>
    <asp:HyperLink id="hlCancel" runat="server" NavigateUrl='<%#
    "Cancel.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") +
    "&op=cancel" %>' Visible='<%# Convert.ToBoolean(DataBinder.Eval(Container,
    "DataItem.PersonStatusCancel"))%>' CssClass="link-text" >
    Cancel
    </asp:HyperLink>
    </asp:panel>
    </ItemTemplate>
    </asp:TemplateColumn>

    --- CODE ENDS ---

    Now, the value of the cookie, when I bring up this page, is 1 which
    satisfies the condition. I guess my question is two-part: 1) What is best
    way to accomplish something like this? 2) If this is best way to do it, then
    what's wrong?
    BobRoyAce, Jan 20, 2005
    #1
    1. Advertising

  2. On of the reasons for not using Visible is that hidden controls don't get
    rendered to client. If there is something to do with hidden controls on
    client side, you can't use Visible.

    Eliyahu

    "BobRoyAce" <> wrote in message
    news:...
    > I am brand new to ASP.NET and am now required to take over maintenance of

    a
    > .NET/C# web application. On one of the pages I'm working on there is a
    > DataGrid which has multiple columns. One of the columns is not databound

    and
    > instead has up to three hyperlinks in it (Edit, Award, and Cancel). A

    couple
    > of the hyperlinks should not be shown in certain cases. Now, mind you, I
    > don't know if it's being done in the way that's best to do it. It looks

    like
    > there is a "panel" being created to contain the hyperlinks that may not be
    > visible. I don't know why though (i.e. why not just set hyperlink's

    Visible
    > property and be done with it without a panel?). That being said, I want to
    > change the page so that one of the hyperlinks does not show (i.e. Visible

    =
    > False) based on a certain value for a session cookie. It's the Award link

    in
    > the code shown below from the .aspx file in question.
    >
    > --- CODE BEGINS ---
    >
    > <asp:TemplateColumn HeaderText="Actions">
    > <ItemStyle HorizontalAlign="Center"></ItemStyle>
    > <ItemTemplate>
    > <asp:HyperLink id="hlEdit" runat="server" NavigateUrl='<%#
    > "Edit.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") %>'
    > CssClass="link-text"> <!--onMouseOver='<%# "javascript:toolTip(\"" +
    > DataBinder.Eval(Container, "DataItem.PersonToolTip") + "\");" %>'
    > onMouseOut="javascript:toolTip();">-->
    > Edit
    > </asp:HyperLink>
    > <asp:panel ID="Panel1" Runat="server" Visible='<%#
    > Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'>
    > <asp:HyperLink id=hlBids runat="server" Visible='<%#
    > Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'
    > NavigateUrl='<%# "Award.aspx?id=" + DataBinder.Eval(Container,
    > "DataItem.PersonID") %>' CssClass="link-text">
    > Award
    > </asp:HyperLink>
    > </asp:panel>
    > <asp:panel ID="panAction" Runat="server" Visible='<%#
    > Convert.ToBoolean(DataBinder.Eval(Container,
    > "DataItem.PersonStatusCancel"))%>'>
    > <asp:HyperLink id="hlCancel" runat="server" NavigateUrl='<%#
    > "Cancel.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") +
    > "&op=cancel" %>' Visible='<%# Convert.ToBoolean(DataBinder.Eval(Container,
    > "DataItem.PersonStatusCancel"))%>' CssClass="link-text" >
    > Cancel
    > </asp:HyperLink>
    > </asp:panel>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > --- CODE ENDS ---
    >
    > Now, the value of the cookie, when I bring up this page, is 1 which
    > satisfies the condition. I guess my question is two-part: 1) What is best
    > way to accomplish something like this? 2) If this is best way to do it,

    then
    > what's wrong?
    >
    >
    Eliyahu Goldin, Jan 20, 2005
    #2
    1. Advertising

  3. BobRoyAce

    BobRoyAce Guest

    huh? I'm not sure what you're saying here. Links are currently being
    "hidden" right now successfully by interrogating data behind the grid (e.g.
    the Cancel link) and setting Visible = False. What doesn't seem to be
    working, and what I need help with, is making things invisible based on a
    session cookie's value. Is that doable?
    BobRoyAce, Jan 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. davetichenor
    Replies:
    1
    Views:
    796
    Eliyahu Goldin
    Oct 30, 2006
  2. rodchar
    Replies:
    0
    Views:
    376
    rodchar
    Nov 26, 2007
  3. susan

    databound column to hyper link column

    susan, Jan 8, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    122
    S. Hussain Akbar
    Jan 12, 2004
  4. Dave
    Replies:
    0
    Views:
    919
  5. Manu
    Replies:
    0
    Views:
    157
Loading...

Share This Page