tags:

views:

88

answers:

4

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>

A: 

I believe you're looking for:

 border-collapse: collapse;

It collapses adjoining borders into one.

Aren
This normally works, but it didn't in my mark up. Thanks.
AGoodDisplayName
A: 

Try setting the DataList CellPadding and CellSpacing attributes to zero.

Mark
Tried this it didn't work, but thanks.
AGoodDisplayName
A: 

This is quite handy for figuring out these issues.

Alex K.
This is handy and I got the sample table to appear as I wanted it to, but when I applied the css to my mark up it didn't resolve the issue. Thanks though.
AGoodDisplayName
A: 

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; }
Josh Stodola
Although its going to bug me that I couldn't get this to work in a datalist, I should have thought about using the gridview in the first place. This works, thanks.
AGoodDisplayName
@AGoodDisplayName I think you probably *could have* got it to work with a DataList, but this is a more appropriate solution, IMO
Josh Stodola
@Josh Stodola Yeah I think eventually it could have figured it out, but how much time is it worth? Thanks again.
AGoodDisplayName