gridview生成時如何去掉style屬性中的border-collapse
在vs2005下用到gridview時,默認(rèn)的情況下gridview控件會在生成的html代碼中的style屬性中加入border-collapse:collapse;
<asp:GridView ID="GridView1" runat="server" BorderWidth="0"></asp:GridView>
綁定數(shù)據(jù)運行后頁面中的代碼為:
<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瀏覽器遇到的問題,邊框合并導(dǎo)致部分邊框線條變粗,GridLines="None" 可以解決
相關(guān)文章
from表單多個按鈕提交用onclick跳轉(zhuǎn)不同action
這篇文章主要介紹了from表單多個按鈕提交用onclick跳轉(zhuǎn)不同action,需要的朋友可以參考下2014-04-04

