我在这里遇到一些GridView的困难,一个客户端要我在单元格之间放一些空格,通常我会做CellSpacing =“5”然而它似乎不起作用,我尝试了一些东西,一切都是改写...
我试过的代码:
<asp:GridView ID="gvShoppingCart" runat="server" CellSpacing="5" Width="100%" AutoGenerateColumns="false">
<some-formating-columns-here />
</asp:GridView>
实际呈现的是:
<table cellpadding="0" cellspacing="0" summary="">
<thead>
<tr class="AspNet-GridView-Header">
<th scope="col">Produit</th>
<th scope="col"> </th>
<th class="Center" scope="col">Quantité</th>
<th class="Right" scope="col"> Prix Unitaire </th>
<th class="Right" scope="col">Prix</th>
</tr>
</thead>
<body-columns-here />
</table>
我现在不知道要添加什么...
有什么建议吗?
答案 0 :(得分:3)
我假设您使用的是reset.css,因此您可能需要考虑执行以下操作;
在你的css文件中;
table {border-collapse:separate; border-spacing:5px}
border-spacing不是跨浏览器,因此您可能还需要在GridView上添加CellSpacing =“5”。
答案 1 :(得分:0)
您是否尝试过使用CSS?如果您知道要应用于HTML元素的类,则可以对该特定CSS类使用CSS填充。我会试一试。
一个例子是:
<asp:GridView ID="gvShoppingCart" runat="server" CssClass="gvShoppingFormat" Width="100%" AutoGenerateColumns="false">
<some-formating-columns-here />
</asp:GridView>
您的CSS类看起来像:
.gvShoppingFormat td {
padding-left: 5px;
padding-right: 5px;
}