BoundField style

joji picture joji · Jan 7, 2011 · Viewed 14.5k times · Source

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?

Answer

gbs picture gbs · Jan 8, 2011

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.