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. Advertisements

  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
    LinkButton, however I would like to remove the underline from the button
    text.
    able to remove the underline on a regular LinkButton, but I haven't found a
    way to do it in the DataGrid.
     
    Alessandro Zifiglio, Feb 23, 2004
    #2
    1. Advertisements

  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. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.