Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8699781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:01:54+00:00 2026-06-13T02:01:54+00:00

I am new to ASP.NET Basically, I have a format style that using for

  • 0

I am new to ASP.NET

Basically, I have a format style that using for a Gridview (example below). This is inside the Gridview. Anytime I create another Gridview in a different page. I would have to copy and paste this style again. I wonder if there is another way (like CSS class) where I can globally save this code and just Reference it in the Gridview?

<AlternatingRowStyle ForeColor="Black"  BackColor="#F7F6F3"  VerticalAlign="top" />
        <HeaderStyle BackColor="#B5DAFF" Font-Bold="True" HorizontalAlign="center" />
        <FieldHeaderStyle BackColor="#CCCCCC" Font-Bold="True" ForeColor="Black"  
        Width="20%" HorizontalAlign="Right" />
        <CommandRowStyle BackColor="Green" Font-Bold="True" />
        <PagerStyle BackColor="Gold" ForeColor="White" HorizontalAlign="Center" />    
        <FooterStyle Font-Bold="True" ForeColor="White"  BackColor="Gold" />

Thank you,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:01:55+00:00Added an answer on June 13, 2026 at 2:01 am

    You can use these properties of the GridView: CssClass, PagerStyle-CssClass and AlternatingRowStyle-CssClass. Then you just define the styles globally in your .css file using the classes you just applied to the GridView.

    Like this sample:

    <asp:GridView ID="gvCustomres" runat="server"  
        DataSourceID="customresDataSource"   
        AutoGenerateColumns="False"  
        GridLines="None"  
        AllowPaging="true"  
        CssClass="mGrid"  
        PagerStyle-CssClass="pgr"  
        AlternatingRowStyle-CssClass="alt">  
        <Columns>  
            <asp:BoundField DataField="CompanyName" HeaderText="Company Name" />  
            <asp:BoundField DataField="ContactName" HeaderText="Contact Name" />  
            <asp:BoundField DataField="ContactTitle" HeaderText="Contact Title" />  
            <asp:BoundField DataField="Address" HeaderText="Address" />  
            <asp:BoundField DataField="City" HeaderText="City" />  
            <asp:BoundField DataField="Country" HeaderText="Country" />  
        </Columns>  
    </asp:GridView>
    

    CSS

    .mGrid {   
        width: 100%;   
        background-color: #fff;   
        margin: 5px 0 10px 0;   
        border: solid 1px #525252;   
        border-collapse:collapse;   
    }  
    .mGrid td {   
        padding: 2px;   
        border: solid 1px #c1c1c1;   
        color: #717171;   
    }  
    .mGrid th {   
        padding: 4px 2px;   
        color: #fff;   
        background: #424242 url(grd_head.png) repeat-x top;   
        border-left: solid 1px #525252;   
        font-size: 0.9em;   
    }  
    .mGrid .alt { background: #fcfcfc url(grd_alt.png) repeat-x top; }  
    .mGrid .pgr { background: #424242 url(grd_pgr.png) repeat-x top; }  
    .mGrid .pgr table { margin: 5px 0; }  
    .mGrid .pgr td {   
        border-width: 0;   
        padding: 0 6px;   
        border-left: solid 1px #666;   
        font-weight: bold;   
        color: #fff;   
        line-height: 12px;   
     }     
    .mGrid .pgr a { color: #666; text-decoration: none; }  
    .mGrid .pgr a:hover { color: #000; text-decoration: none; }
    

    This link has full details: ASP.NET GridView makeover using CSS

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a asp.net that I need to display an XML document (straight
I'm playing around with using ASP.NET MVC3 and have a very simple site that
I have recently found a strange behaviour inside of the ASP.NET DropDownList that I
I'm new to ASP.NET MVC so this may be a stupid question. I have
I have a legacy ASP.Net web application that is basically used to process web
Basically I have a gridview that is using a list as it's datasource. How
I'm using ASP.Net/C# and I have a form that allows people to add information
i'm new to asp.net mvc.. so basically i just build up a two page
So I am fairly new to ASP.NET MVC and Windows Live Connect API. Basically
I have a new asp.net mvc project and i am trying to figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.