Default Inline Styles
In implementing a master page based template across the site, this testing page or its dependencies may have been moved. Therefore, some of the references have been changed possibly including master page friendly techniques like application root relative references. They are not original.
[chroniclemaster1, 2008/11/08]
As we saw on the last page, ASP.NET has some less than desirable default behavior when it comes to controlling the appearance of the web page. Preferably, we would liked to have used CSS to control the look of the GridView control. However, .NET uses some default inline styles that interfere with our goal. So why don't we see what we can still manage, shall we? Here's the code we started with last time...
<asp:GridView ID="gvRolesData" runat="server" DataSourceID="adsRolesData"></asp:GridView>
<asp:AccessDataSource ID="adsRolesData" runat="server" DataFile="~/App_Data/ASPNetDB.mdb"
SelectCommand="SELECT * FROM [vw_aspnet_Roles]"></asp:AccessDataSource>
This resulted in a basically clean HTML table that included these inline styles.
<table cellspacing="0" rules="all" border="1" id="gvRolesData" style="border-collapse:collapse;">
The cellspacing attribute is old HTML4; it's equivalent to the table cell's CSS margin. It combines with the border-collapse style rule to indicate that there should be no spacing between cells and they should share a border. In this case a 1px border specified by the border attribute, border="1". Now strictly speaking the border attribute specifies the border around the table, but the rules attribute indicates that each table cell should also take a border producing a complete grid. The result of the default style is a table that looks like this.
| PatientID | Name |
| 1 | Hotel Calls |
| 2 | Katy Peril |
| 3 | Mrs. Roberts |
| 4 | Mr. Johns |
| 5 | Kinko's |
| 6 | Mr. Wilson |
| 7 | Mrs. Le Calvez |
| 8 | Mrs. Haversham |
| 9 | Mr. Grissom |
| 10 | Bill P. |
| 11 | Mr. Johnson |
| 12 | June Beatermeyer |
| 13 | Nicholas Nickelby |
| 15 | Willa Cather |
| 16 | Desiree Cloud |
| 17 | Bobby McGee |
| 19 | Minerva Stanley |
| 20 | Miles Davis |
| 27 | Asa |
| 28 | Alex Anderson |
| 29 | Willie Nelson |
| 30 | Willie Nelson |
| 31 | Lisa Biesele |
| 32 | Dora the Explorer |
| 33 | Mouse, Mickey |
Skip to Main Points