Problem: I need to have many GridView control used all over my Application and need to ensure standard look and feel across all of them.
Solution: Use the default style templates provided out of box. This is a good way to have standard look and feel, but adds a lot of code in your aspx page which is hard to manage and looks dirty. It becomes cumbersome if the client later makes a comment saying “I do not want Blue Headers, make it Black!” you would need to change every possible GridView in your application.
A more elegant way of achieving the same would be to have your own CSS file which could be used by all the GridView across your application. Below is a sample CSS file that I often use/re-use for GridView controls
Now where ever your have to place a GridView control, include this file in the page and refer the CSS clases at right places. Below is one such snippet of same:
<asp:GridView id="gridViewMessageList" Runat="server" GridLines="None" CssClass="gridView">
1. Maintenance is directly proportional to clarity and size of the code you write.
2. Avoids repeatation of same styling related code across the project.
3. Gives a single point of controling the styles across the application.
4. Improves the performace as the Asp.Net parser now only needs to parse the CSS file once and not do the same parsing of the style for other GridView within a page again.
Problem Generalization: Not only does this apply for GridView, but for any other control we use. Try to make all the styling in CSS as far as possible.
Thanks & Regards,
SMTS || Microsoft Technology Practice || Bridgestone - Tyre Link || Persistent Systems || 3023-6258
DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Pvt. Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Pvt. Ltd. does not accept any liability for virus infected mails.