gridview生成时如何去掉style属性中的border-collapse
作者:bea
在vs2005下用到gridview时,默认的情况下gridview控件会在生成的html代码中的style属性中加入border-collapse:collapse; 代码如下: <asp:GridView ID="GridView1" runat="server" BorderWidth="0"></asp:GridView> 绑定数据运行后页面中的代码为: <table cellspacing="0" rules="all"
在vs2005下用到gridview时,默认的情况下gridview控件会在生成的html代码中的style属性中加入border-collapse:collapse;
代码如下:
<asp:GridView ID="GridView1" runat="server" BorderWidth="0"></asp:GridView>
绑定数据运行后页面中的代码为:
<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>
gridview控件就自动给加上了:border-collapse:collapse;
要想去掉这个自动加入的代码只要将 CellSpacing="-1"就可以了,加上后html的代码为
<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>
补充一点:
GridLines="None" 不显示单元格边框 CellSpacing="-1" 去掉GridView style中的border-collapse:collapse;样式
备注:在firefox浏览器遇到的问题,边框合并导致部分边框线条变粗,GridLines="None" 可以解决
有用 | 无用
代码如下:
<asp:GridView ID="GridView1" runat="server" BorderWidth="0"></asp:GridView>
绑定数据运行后页面中的代码为:
<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>
gridview控件就自动给加上了:border-collapse:collapse;
要想去掉这个自动加入的代码只要将 CellSpacing="-1"就可以了,加上后html的代码为
<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>
补充一点:
GridLines="None" 不显示单元格边框 CellSpacing="-1" 去掉GridView style中的border-collapse:collapse;样式
备注:在firefox浏览器遇到的问题,边框合并导致部分边框线条变粗,GridLines="None" 可以解决
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 一个css与js结合的下拉菜单支持主流浏览器
- Javascript获取当前日期的农历日期代码
- javascript中通过arguments参数伪装方法重载
- 利用原生JavaScript获取元素样式只是获取而已
- javascript学习笔记(八)正则表达式
- javascript学习笔记(七)Ajax和Http状态码
- javascript学习笔记(六)数据类型和JSON格式
- javascript学习笔记(五)原型和原型链详解
- JavaScript中获取高度和宽度函数总结
- 5个可以帮你理解JavaScript核心闭包和作用域的小例子
- JavaScript中获取样式的原生方法小结
- 吐槽一下我所了解的Node.js
- Node.js 的异步 IO 性能探讨
- JS中的form.submit()不能提交表单的错误原因
- js数值计算时使用parseInt进行数据类型转换(jquery)
- js交换排序 冒泡排序算法(Javascript版)
- Javascript获取当前时间函数和时间操作小结
- js事件绑定快捷键以ctrl+k为例
- 显示今天的日期js代码(阳历和农历)