ASP.NET数据列表-列宽和缩进面板

ASP.NET数据列表-列宽和缩进面板,asp.net,css,Asp.net,Css,下面的代码运行良好,但列之间的距离太近了。有没有办法设置每列的宽度?还有,有没有办法缩进整个“pnlChildView” 谢谢 <asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyList" runat="server" Width="100%" DataKeyField="Company" UseAccessibleHeader="tru

下面的代码运行良好,但列之间的距离太近了。有没有办法设置每列的宽度?还有,有没有办法缩进整个“pnlChildView”

谢谢

<asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyList"  
              runat="server" Width="100%" DataKeyField="Company"
              UseAccessibleHeader="true" CssClass="books"
              HeaderStyle-CssClass="header" ItemStyle-CssClass="item"
              AlternatingItemStyle-CssClass="alternating"> 
    <ItemTemplate>
        <asp:LinkButton ID="LinkButton1" runat="server" Text="+" 
                        CommandArgument='<%#Container.ItemIndex%>'
                        OnCommand="LinkButton1_Command"  
                        Font-Underline="false">
        </asp:LinkButton>
        <%#Eval("Row")%>
        <%#Eval("Company")%>
        <asp:Panel ID="pnlChildView" runat="server" style="margin-right:50px;">
            <asp:DataList ID="childList" runat="server" Width="100%">
                <ItemTemplate>
                    <tr>
                        <td><%#Eval("FirstName")%></td>
                        <td><%#Eval("LastName")%></td>                        
                    </tr>
                </ItemTemplate>
            </asp:DataList>
        </asp:Panel>
    </ItemTemplate>
</asp:DataList>

尝试将样式应用于TDs,例如:

<td style="width: 200px;"><%#Eval("FirstName")%></td>
<td style="width: 300px;"><%#Eval("LastName")%></td>  

根据需要使用填充和其他属性对其进行调整


对于主面板,而不是
style=“margin right:50px;
尝试
style=“padding left:50px
将其缩进。

您可以使用
DataList
CellPadding
属性在列之间生成空格,如下所示:

<asp:DataList CellPadding="10"
<asp:Panel ID="pnlChildView" runat="server" style="margin:50px;">
注:
margin
本身将对方框的所有四个侧面应用相同的边距值。对方框的各个侧面使用
左侧边距
顶部边距
右侧边距
底部边距


了解更多信息。

感谢您的回复。我尝试了您的建议,似乎效果不错。但不知何故,当我尝试style=“width:30%”时,使用百分比作为宽度,它不起作用。。知道为什么吗?@milacay percentage width可能非常棘手,它应该是某个内容的百分比,这意味着容器必须具有固定的宽度(例如TR/TDs的表父级)。我建议不要使用百分比。如果您唯一的问题是列靠得太近,请使用“左填充”、“右填充”样式,而不是“宽度”。谢谢您的帮助。一个简单的问题。这是显示每列边框线的一种方式吗?我尝试了这个“”,但它看起来真的很糟糕,每重复一行里面都有一个小盒子,里面有值。它看起来不像普通的HTML表/行。请给出建议。添加到主表样式(或者我想在您的数据列表中)
style=“border collapse:collapse”
没有运气。可能DataList是用于显示行的错误类型。无论如何,谢谢你。
<asp:Panel ID="pnlChildView" runat="server" style="padding:50px;">