DataGrid LinkButton question

Discussion in 'ASP .Net Web Controls' started by Angela, Feb 23, 2004.

  1. Angela

    Angela Guest

    I have a ButtonColumn in my DataGrid and I used the ButtonColumnType LinkButton, however I would like to remove the underline from the button text

    I tried

    ButtonColumn butTemp = new ButtonColumn()
    butTemp.ButtonType = ButtonColumnType.LinkButton
    butTemp.CommandName = "EDIT"
    butTemp.Text = <determined by a database entry
    butTemp.HeaderText = "Document Description"
    butTemp.ItemStyle.Font.Underline = false

    But that doesn't remove the underline. Is there a way to remove the underline

    I tried removing the line with a regular LinkButton on a WebForm and I was able to remove the underline on a regular LinkButton, but I haven't found a way to do it in the DataGrid

    this is how I removed the underline on the LinkButton

    LinkButton lb = new LinkButton()
    lb.Attributes.Add("text-decoration", "none");
     
    Angela, Feb 23, 2004
    #1
    1. Advertising

  2. hi Angela,
    The css style below will set the following styling to all anchor
    elements(hyperlinks)
    <STYLE TYPE="text/css">
    <!--
    A { color: red; text-decoration: none} /* unvisited link */
    A:visited { color: blue;text-decoration: none } /* visited link */
    A:active { color: green; text-decoration: none} /* active link */
    A:hover { color: gold;text-decoration: none } /* hover or mousover link
    */
    //-->
    </STYLE>


    whereas the example below will set style on a specific anchor element whose
    class attribute is set to the following class.

    <STYLE TYPE="text/css">
    .Buttoncolumn { color: darkred; font-size:14pt; } /* unvisited link */
    .Buttoncolumn:visited { color: indianred; text-decoration: none} /*
    visited link */
    .Buttoncolumn:active { color: gold;text-decoration: none } /* active
    link */
    .Buttoncolumn:hover { color: darkgreen; text-decoration: none} /*
    hover or mousover link */
    </STYLE>

    now just pass the class to your bound column :

    butTemp.ItemStyle.CssClass = "Buttoncolumn"


    For a quick tutorial reference below :
    http://www.w3schools.com/css/css_pseudo_classes.asp
    "Angela" <> wrote in message
    news:...
    > I have a ButtonColumn in my DataGrid and I used the ButtonColumnType

    LinkButton, however I would like to remove the underline from the button
    text.
    >
    > I tried:
    >
    > ButtonColumn butTemp = new ButtonColumn();
    > butTemp.ButtonType = ButtonColumnType.LinkButton;
    > butTemp.CommandName = "EDIT";
    > butTemp.Text = <determined by a database

    entry>
    > butTemp.HeaderText = "Document Description";
    > butTemp.ItemStyle.Font.Underline = false;
    >
    > But that doesn't remove the underline. Is there a way to remove the

    underline?
    >
    > I tried removing the line with a regular LinkButton on a WebForm and I was

    able to remove the underline on a regular LinkButton, but I haven't found a
    way to do it in the DataGrid.
    >
    > this is how I removed the underline on the LinkButton:
    >
    > LinkButton lb = new LinkButton();
    > lb.Attributes.Add("text-decoration", "none");
     
    Alessandro Zifiglio, Feb 23, 2004
    #2
    1. Advertising

  3. Hi Angela,

    Thank you for posting in the community!

    You can just follow Alessandro's reply to use CssClass to hide the
    underline.

    What I want to add is why ButtonColumn.ItemStyle.Font.Underline = false
    does not work:
    LinkButton will render as <a> html tag, and the default style for <a> will
    have underline. So the underline is a part of the link element(<a>), not a
    part of Font(Which will default has no underline, you can determine this
    through Response.Write(ButtonColumn.ItemStyle.Font.Underline.ToString())),
    so you should use css attribute "text-decoration: none" to hide the
    underline.

    Thank you for your patience and cooperation. If you have any questions or
    concerns, please feel free to post it in the group. I am standing by to be
    of assistance.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], Feb 24, 2004
    #3
  4. Hi Angela,

    Does my reply make sense to you?

    If you have anything unclear, please feel free to feedback. I will help you.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], Feb 27, 2004
    #4
    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. Vik
    Replies:
    0
    Views:
    352
  2. Mark
    Replies:
    1
    Views:
    492
  3. Sathyaish
    Replies:
    3
    Views:
    3,172
    Sathyaish
    Sep 8, 2005
  4. Dotnet_Is_Love

    Question about LinkButton on datagrid

    Dotnet_Is_Love, Sep 24, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    115
    Alvin Bruney
    Sep 27, 2003
  5. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    218
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page