AGoodDisplayName
AGoodDisplayName

Reputation: 5653

Space Between Table Rows

This should be a simple problem, but I am have a tough time getting the html to display the way I want it...

The problem is the space between my table rows...I don't want space between my rows. I just want my table to look like a spreadsheet with black borders. I am using a datalist and have a table in the datalist control's templates. I have been messing with this for a couple of hours now and I have tried a few different variations of CSS and table attributes. Can anyone tell me where I am going wrong? Below is my current mark up.

<style type="text/css">
.tdHeader
{
    border-color: Black;
    border-style: solid;
    border-width: 1px;
    font-family: Arial;
    font-size: 8pt;
    margin: 0;
    background-color: #DCDCDC;
    font-weight: bold;
}
.tdBorder
{
    border-color: Black;
    border-style: solid;
    border-width: 1px;
    font-family: Arial;
    font-size: 8pt;
    margin: 0;
    text-align: center;
}
.trNoSpace
{
    margin: 0;
    padding: 0;
}
</style>

<asp:DataList ID="DataList1" runat="server" DataKeyField="Oid" 
DataSourceID="xdsHUDEligibilityMember">
<HeaderTemplate>
    <table cellspacing="0" width="600">
        <tr class="trNoSpace">
            <td class="tdHeader" width="100">Household Member Number
            </td>
            <td class="tdHeader">Household Member Name
            </td>
            <td class="tdHeader">Age of Household Member
            </td>
        </tr>
</HeaderTemplate>
<ItemTemplate>
        <tr class="trNoSpace">
            <td class="tdBorder">
                <asp:Label ID="Label2" runat="server" Text='<%# Eval("Oid") %>' />
            </td>
            <td class="tdBorder">  
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("FullName") %>' />
            </td>
            <td class="tdBorder">
                <asp:Label ID="AgeAtEffectiveDateLabel" runat="server" Text='<%# Eval("AgeAtEffectiveDate") %>' />
            </td>
        </tr>
</ItemTemplate>    
<FooterTemplate>
        <tr class="trNoSpace">
            <td class="tdBorder">
            </td>
            <td class="tdBorder">
            </td>
            <td class="tdBorder">
            </td>
        </tr>
    </table>
</FooterTemplate>

Upvotes: 1

Views: 29894

Answers (5)

Oddacon
Oddacon

Reputation: 319

GridView's are rendered as tables, and to make spacing simple change the padding between the table colums. First create a a main css name for the GridView:

<asp:GridView ID="GridView1" CssClass="MyGridView" runat="server">

then in the css change the table colums padding as desired:

`.MyGridView{
border: none;

}

 .MyGridView tr{
  text-align: left;
  vertical-align: top;

 }

.MyGridView td{
  vertical-align: top;
 padding-bottom: 100px;

  }`

Upvotes: 0

Josh Stodola
Josh Stodola

Reputation: 82523

First, I think you need to be using the GridView control. Then in the markup, be sure to set cellpadding and cellspacing to zero and then apply the following CSS...

table { border-collapse: collapse; }
table tr, table td, table th { border: solid 1px #000; margin: 0; padding: 0; }

Upvotes: 2

Alex K.
Alex K.

Reputation: 175996

This is quite handy for figuring out these issues.

Upvotes: 0

Mark M
Mark M

Reputation: 976

Try setting the DataList CellPadding and CellSpacing attributes to zero.

Upvotes: 0

Aren
Aren

Reputation: 55976

I believe you're looking for:

 border-collapse: collapse;

It collapses adjoining borders into one.

Upvotes: 0

Related Questions