When the GridView is used under VS2005, by default the GridView control adds border-collapse:collapse to the style attribute in the generated HTML code;
Copy Code code as follows:
<asp:gridview id= "GridView1" runat= "server" borderwidth= "0" ></asp:GridView>
The code in the post-run page of the bound data is:
<table cellspacing= "0" rules= "all" border= "0" id= "GridView1" style= "Border-width:0px;border-collapse:collapse"; >
<tr>
<th scope= "col" >id</th><th scope= "col" >name</th>
</tr> <tr>
<td>1</td><td>1</td>
</tr><tr>
<td>2</td ><td>2</td>
</tr>
</table>
The GridView control is automatically added to: border-collapse:collapse;
To get rid of this automatically added code, just put the cellspacing= "-1" on it, plus the HTML code for
<table rules= "All" border= "0" id= "GridView1" style= "border-width:0px"; >
<tr>
<th scope= "col" >id</th><th scope= "col" >name</th>
</tr> <tr>
<td>1</td><td>1</td>
</tr><tr>
<td>2</td ><td>2</td>
</tr>
</table>
Add one point:
Gridlines= "None" does not display cell borders
cellspacing= "-1" removes the Border-collapse:collapse style from the GridView style
Note: Problems encountered in the Firefox browser, border merge caused some border lines to become thicker, gridlines= "None" to resolve