6

How can I give style for BoundField?

I'm using BoundField in Gridview. Tt shows an underline and an unwanted color.

How do I remove underline and color?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
joji
  • 61
  • 1
  • 1
  • 4

1 Answers1

9

Depending on what bound field you are trying it might vary a little but here is an example. Each fields has properties for various styles and you can set CssClass as well.

CommandField

.select {
    text-decoration: none;
    color: Red;
}
<asp:CommandField ShowSelectButton="True">
    <ControlStyle CssClass="select" />
</asp:CommandField>

BoundField

.product {
    color: Blue;
}    
<asp:BoundField DataField="ProductName" HeaderText="Product Name" ItemStyle-CssClass="product">
    <ItemStyle CssClass="product" />
</asp:BoundField>

Go to GridView Properties → Columns and you will find all your fields listed there. There you can set the style properties of BoundField.

Another alternative is using a Template Field where you will have more control.

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
gbs
  • 7,196
  • 5
  • 43
  • 69