Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

How to change the Grdview color using css.

Thanks
Posted

Hi,

You can use different css in a GridView for changing style of its different parts like Rows, AlternateRow, Header, Footer etc

C#
        <asp:gridview id="GridView1" xmlns:asp="#unknown">
            runat="server"
            ShowFooter="true"
            AutoGenerateColumns="false"
            DataSourceID="SqlDataSource1"
            CssClass=""
            RowStyle-CssClass=""
            AlternatingRowStyle-CssClass=""
            HeaderStyle-CssClass=""
            FooterStyle-CssClass="">
</asp:gridview>
 
Share this answer
 
Comments
Syed SufiyanUddin 16-Apr-12 6:22am    
boss, how to create a css class. please help me in sending code.
Deepak_Sharma_ 16-Apr-12 6:29am    
The simplest way to create a CSS class is to define it inside head tag like :

<style type="text/css">
.GridStyle
{
background-color:Teal;
}
</style>


Now you can use CssClass="GridStyle" in your GridView
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900