Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DataGrid LinkButton question

0 views
Skip to first unread message

Angela

unread,
Feb 23, 2004, 1:11:11 PM2/23/04
to
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

unread,
Feb 23, 2004, 1:59:06 PM2/23/04
to
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" <Angela....@globalcrossing.com> wrote in message
news:FAA952D7-9310-40D6...@microsoft.com...

"Jeffrey Tan[MSFT]"

unread,
Feb 23, 2004, 9:56:18 PM2/23/04
to

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]"

unread,
Feb 26, 2004, 8:38:05 PM2/26/04
to

Hi Angela,

Does my reply make sense to you?

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

0 new messages