How to get rid of the border-collapse_javascript technique in the style attribute when the GridView is generated

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.