Change GridView Header Text Color and Background color

shermi
 
on Feb 21, 2013 02:05 AM
21896 Views
<asp:GridView ID="Grdschoolnames" runat="server" AutoGenerateColumns="False"   HeaderStyle-Font-Size="Large"
      ShowHeader="true" GridLines="None" width="100%" DataKeyNames="SNo" ondatabound="Grdschoolnames_DataBound"  
         onrowcommand="Grdschoolnames_RowCommand" onrowdatabound="Grdschoolnames_RowDataBound" Font-Bold="true"> 
             <HeaderStyle ForeColor="White" Font-Bold="True" 
       BackColor="White"></HeaderStyle>     
                 <Columns> 
           <asp:TemplateField HeaderText="School Names"  HeaderStyle-HorizontalAlign="Left">
          <ItemTemplate>
           <asp:LinkButton ID="Lnkbtn" runat="server"  ToolTip="Setup Academic Calender"   CommandArgument='<%# Eval("SNo") %>' CommandName="redirect"> <asp:Label ID="Label5" runat="server" Text='<%#Eval("SName")%>' ></asp:Label></asp:LinkButton>
              
               
               
       <asp:HyperLink ID="Hpleditschool" runat="server"  NavigateUrl='<%#"javascript:popupEditSchoolInfo("+DataBinder.Eval(Container.DataItem,"SNo").ToString()+")" %>'>
           <asp:Image ID="Image2" ImageUrl="~/DesktopModules/IslamicSchools/images/edit-pencil.gif" runat="server" ToolTip="Click To Edit School Profile"/>
           </asp:HyperLink>
          <%-- <a id="A2" runat="server"  title="Edit School Info"  href='<%#"javascript:popupEditSchoolInfo("+DataBinder.Eval(Container.DataItem,"SNo").ToString()+")" %>'><%#Eval("SName")%><asp:Image ID="Image1" runat="server" ToolTip="Clik To Edit School Profile" ImageUrl="~/img/edit-pencil.gif" /> </a>--%>
      </ItemTemplate>
       <%--   <HeaderStyle HorizontalAlign="Left" Font-Bold="true"></HeaderStyle>--%>
           </asp:TemplateField>
    <asp:TemplateField HeaderText="Address" HeaderStyle-HorizontalAlign="Left">
           <ItemTemplate >
              <asp:Label ID="Label1" runat="server" Text='<%# Eval("Address")%>' >
		</asp:Label>
           </ItemTemplate>
               </asp:TemplateField>
           <asp:TemplateField HeaderText="Telephone" HeaderStyle-HorizontalAlign="Left">
           <ItemTemplate>
               <asp:Label ID="Label4" runat="server" Text='<%# Eval("PhoneNumber") %>'></asp:Label>
           </ItemTemplate>
            </asp:TemplateField>
           <asp:TemplateField HeaderText="Email" HeaderStyle-HorizontalAlign="Left">
           <ItemTemplate >
               <asp:Label ID="Label2" runat="server" Text='<%# Eval("Email") %>'></asp:Label>
           </ItemTemplate>
           </asp:TemplateField>
           <asp:TemplateField HeaderText="Principal" HeaderStyle-HorizontalAlign="Left">
           <ItemTemplate >
               <asp:Label ID="Label3" runat="server" Text='<%# Eval("Principal") %>'></asp:Label>
           </ItemTemplate>
           </asp:TemplateField>
       </Columns>

<HeaderStyle BackColor="#3D5D85" Font-Bold="True" ForeColor="White"></HeaderStyle>
    </asp:GridView>

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mustafa
 
on Feb 21, 2013 04:37 AM
on Feb 21, 2013 04:38 AM

Try this Sample

 

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" HeaderStyle-Font-Size="Large" HeaderStyle-BackColor="#2E3C59"
            HeaderStyle-ForeColor="White">
            <Columns>
                <asp:BoundField HeaderText="Name" DataField="Text" />
                <asp:ImageField HeaderText="Image" DataImageUrlField="Value" ControlStyle-Height="100"
                    ControlStyle-Width="100" />
            </Columns>
        </asp:GridView>