Welcome to MSDN Blogs Sign in | Join | Help

Cleaning up Default GridView Markup

I saw an interesting question today from a customer related to some of the default markup for a GridView. The following code:

<asp:GridView ID="GridView1" runat="server">
</
asp:GridView>

Will generate this markup in the web page:

<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

</table>

Adding:

CellSpacing="-1" GridLines="None"

Will clean the markup considerably generating this in the web page:

<table border="0" id="GridView1">

There currently is no way to get rid of the final Border="0" but the above technique does clean up the table considerably.

Published Wednesday, March 26, 2008 3:21 PM by scothu

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker