I'm using CSS to style a GridView. I have everything working fine except for the padding in the cells that contain the data. I've googled and found multiple solutions that involve another style on the Item when using Bound fields. However, I am not using bound fields. I am binding to a List(Of MyObject). How would I add padding around the data in the cells?
One almost-solution was to style the TR and TD elements. This works fine ... until I add paging to the GridView. The padding also applies to the page counters, which I do not want. This is because the paging row is just another TR in the rendered HTML table.
Here's a little of what I have going on:
.aspx Page:
<asp:GridView ID="gvTerritories"
runat="server"
CssClass="gridview"
AutoGenerateSelectButton="True"
GridLines="None"
AllowPaging="true"
PageSize="10">
<HeaderStyle CssClass="gridViewHeader" />
<RowStyle CssClass="gridViewRow" />
<AlternatingRowStyle CssClass="gridViewAltRow" />
<SelectedRowStyle CssClass="gridViewSelectedRow" />
<PagerStyle CssClass="gridViewPager" />
</asp:GridView>
CSS:
.gridview {
font-family: Arial;
background-color: #FFFFFF;
border: solid 1px #CCCCCC;
}
.gridViewHeader {
background-color: #0066CC;
color: #FFFFFF;
padding: 4px 50px 4px 4px;
text-align: left;
border-width: 0px;
border-collapse: collapse;
}
.gridViewRow {
background-color: #99CCFF;
color: #000000;
border-width: 0px;
border-collapse: collapse;
}
.gridViewAltRow {
background-color: #FFFFFF;
border-width: 0px;
border-collapse: collapse;
}
.gridViewSelectedRow {
background-color: #FFCC00;
color: #666666;
border-width: 0px;
border-collapse: collapse;
}
.gridViewPager
{
background-color: #0066CC;
color: #FFFFFF;
text-align: left;
padding: 0px;
}
The gridViewHeader
class doesn't apply the padding to the TH row. The gridViewPager
class doesn't apply the padding of 0px to the rendered HTML in the "pager" TR.