I use CSS to create a gridview. Everything works fine for me, except for filling in the cells containing the data. I searched Google and found some solutions that are related to a different style in Item when using Bound fields. However, I do not use related fields. I am attached to a list (from MyObject). How can I add padding to data in cells?
One solution is the style of the TR and TD elements. This works fine ... until I add paging to the GridView. Indentation also applies to page counters that I don't want. This is because the paging bar is another TR in the displayed HTML table.
Here is a little of what is going on with me:
.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;
}
gridViewHeader TH. gridViewPager 0px HTML "" TR.