简体   繁体   English

如何在asp.net中的数据列表控件中更改列宽

[英]how to change column width inside datalist control in asp.net

I have a datalist control in which data is shown in 3 <td> as shown in html . 我有一个datalist控件,其中数据显示在3 <td> ,如html所示。

 <asp:DataList ID="DataList1" runat="server" 
    onitemdatabound="DataList1_ItemDataBound" Width="400px">
<ItemTemplate>
<table style="width: 130px"><tr><td style="width:65px;">
    <asp:Image ID="Image1" runat="server" Width="59px" Height="60px" 
        ImageUrl='<%# "~/User/UserPic/" + Eval("reg_pic") %>' /></td>
    <td style="width:162px;" class="wdth150">
        <asp:Label
        ID="lbl_nam" runat="server" Text='<%# Eval("reg_nam") %>' ForeColor="White"></asp:Label><br />
        <asp:Label ID="lbl_ad" runat="server" Text='<%# Eval("reg_age") %>' 
            ForeColor="White"></asp:Label>
        </td><td style="width:109px" class="wdth120"></td><td>
            <asp:LinkButton ID="LinkButton2" runat="server">Proceed</asp:LinkButton></td></tr>
        </table>
</ItemTemplate>
</asp:DataList>

My problem is that these records are appear very closely i want to show some gap between them i tried to use style="width:120px" but that didn't work. 我的问题是这些记录显示得非常紧密,我想显示它们之间的间隙,我尝试使用style="width:120px"但这style="width:120px"

You probably need to set padding in class or style to put space at the end of columns 您可能需要在类或样式中设置填充以在列的末尾放置空间

padding:5px;

The padding CSS property sets the required padding space on all sides of an element. padding CSS属性可在元素的所有面上设置所需的填充空间。 The padding area is the space between the content of the element and its border. 填充区域是元素内容与其边界之间的空间。 Negative values are not allowed. 不允许使用负值。

The padding property is a shorthand to avoid setting each side separately (padding-top, padding-right, padding-bottom, padding-left), reference . padding属性是避免分别设置每侧(padding-top,padding-right,padding-bottom,padding-left), reference的简写形式。

use 采用

<table cellpadding="0" cellspacing="0" width="100%">

and try to give width in percentage instead of Pixels ... 并尝试以percentage而不是Pixels给出宽度...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM