lulutanseco
lulutanseco

Reputation: 423

Forcing Gridview Header font bold to false in ASP.NET

I am having a problem in forcing gridview header to "unbold". I tried using the Gridview parameter for header font style but it doesn't really work. Unfortunately, all other methods I tried did not work.

  1. Using CSS Class
.headercell

      {

       font-weight: normal;

       font-size: 12px;

       font-family: "Franklin Gothic Book"

      }
  1. Programmatically using Row Data Bound

    If e.Row.RowType = DataControlRowType.Header Then
        For i = 0 To GridView1.Columns.Count - 1
            GridView1.Columns(i).HeaderStyle.Font.Bold = False
        Next
    End If
    

What would be the most efficient way to set the gridview header to unbold?

UPDATE (ASPX CODE):

   <asp:GridView ID="GridView1" runat="server" BackColor="White" 
     BorderColor="#333333" BorderStyle="Solid" BorderWidth="2px"
     CellPadding="3" Font-Bold="false" Font-Overline="False" 
     Font-Size="Small" Font-Underline="False" HtmlEncode="false">
      <RowStyle ForeColor="#000066" Height="23px" HorizontalAlign="Center" 
         VerticalAlign="Middle" />
      <FooterStyle BackColor="White" ForeColor="#000066" />
      <PagerStyle BackColor="White" ForeColor="#000066"
         HorizontalAlign="Left" />
       <SelectedRowStyle BackColor="#669999" Font-Bold="True"
         ForeColor="White" />
        <HeaderStyle BackColor="#002851" Font-Bold="False" 
          CssClass="headercell" ForeColor="White" HorizontalAlign="Left"
          VerticalAlign="Middle" />
      <Columns>
       <asp:TemplateField HeaderText="STATUS" ShowHeader="False"
          Visible="True">
          <ItemTemplate>
           <asp:Button ID="Btn1" runat="server" CommandArgument='<%#
           DataBinder.Eval(Container, "RowIndex") %>'
           CommandName="Btn1_cmd">                                                                    

   </ItemTemplate>
  </asp:TemplateField>
  </Columns>
 </asp:GridView>

Upvotes: 2

Views: 9572

Answers (4)

lulutanseco
lulutanseco

Reputation: 423

This is the cssclass I added to the Gridview:

 .Grid, .Grid th, .Grid td
   {
  border-color: #CCCCCC;
  font-family: Franklin Gothic Book; 
  font-size: 12px;
  font-weight: normal; 
   }

In the source code, I just added CssClass="Grid" to the Gridview (not in header cssclass).

Upvotes: 0

Shyju
Shyju

Reputation: 203

Add a CssClass namely "gvstyling" to your gridview

Write a css just like this...

    .gvstyling th
    {
        font-size: 12px;
        font-weight: normal;
    }

Upvotes: 0

Izzy
Izzy

Reputation: 6866

You can use HeaderStyle-Font-Bold on your <asp:BoundField /> So just set it to false as following

HeaderStyle-Font-Bold="false"

Upvotes: 2

Rahul Nikate
Rahul Nikate

Reputation: 6337

Try below :

  th {
        font-weight: normal;
    }

Upvotes: 0

Related Questions