Home > Article > Web Front-end > How to remove the border-collapse_javascript technique in the style attribute when generating gridview
When using gridview under vs2005, by default the gridview control will add border-collapse:collapse;
to the style attribute in the generated html code<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: border-collapse:collapse;
To remove this automatically added code, just add CellSpacing="-1", and the html code after adding it is
<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>
Additional point:
GridLines="None" does not display cell borders
CellSpacing="-1" Remove border-collapse:collapse; style in GridView style
Note: The problem encountered in the Firefox browser is that border merging causes some border lines to become thicker. GridLines="None" can solve the problem