Home  >  Article  >  Web Front-end  >  How to remove the border-collapse_javascript technique in the style attribute when generating gridview

How to remove the border-collapse_javascript technique in the style attribute when generating gridview

WBOY
WBOYOriginal
2016-05-16 16:34:521700browse

When using gridview under vs2005, by default the gridview control will add border-collapse:collapse;

to the style attribute in the generated html code

Copy code The code is as follows:

0271d8be4cec91ef379ce03d053d6c1334ca5f6ede99fa395a5999b2911dfeb4

The code in the page after binding data is run:
<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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn