转发器itemtemplate中的html表格宽度无法设置

时间:2013-03-12 03:14:06

标签: html asp.net html-table repeater

我正在尝试调整HTML表格中作为ASP转发器项目持有者的列的宽度。

<asp:Repeater id="viewproduct" runat="server"> 
 <HeaderTemplate>
  <table id="grid">
    <thead >
       <tr>
         <th width="20px" data-field="check"></th>
         <th data-field="level">Status</th>
         <th data-field="Class">Username</th>
       </tr>
    </thead>
    <tbody>``
  </HeaderTemplate>
  <ItemTemplate>
      <tr>
      <td width="20px"><asp:CheckBox ID="CheckApprove" runat="server" Width="20px" /></td>                   
      <td><asp:Label ID="status" runat="server"
            Text='<%#DataBinder.Eval(Container.DataItem, "Status")%>'></asp:Label></td> 
      <td><asp:Label ID="name" runat="server"
            Text='<%#DataBinder.Eval(Container.DataItem, "name")%>'></asp:Label></td>
      </tr>
    </ItemTemplate>
  <FooterTemplate>
    </tbody>
    </table>
  </FooterTemplate>
</asp:Repeater>

请注意,标题遵循宽度,但内容不是。为什么? 这是我的表目前的样子:

2 个答案:

答案 0 :(得分:2)

Use style tag in th and td
<asp:Repeater id="viewproduct" runat="server"> 
 <HeaderTemplate>
  <table id="grid">
    <thead >
       <tr>
         <th style="width:20px;" data-field="check"></th>
         <th data-field="level">Status</th>
         <th data-field="Class">Username</th>
       </tr>
    </thead>
    <tbody>``
  </HeaderTemplate>
  <ItemTemplate>
      <tr>
      <td style="width:20px;" ><asp:CheckBox ID="CheckApprove" runat="server" Width="20px" /></td>                   
      <td><asp:Label ID="status" runat="server"
            Text='<%#DataBinder.Eval(Container.DataItem, "Status")%>'></asp:Label></td> 
      <td><asp:Label ID="name" runat="server"
            Text='<%#DataBinder.Eval(Container.DataItem, "name")%>'></asp:Label></td>
      </tr>
    </ItemTemplate>
  <FooterTemplate>
    </tbody>
    </table>
  </FooterTemplate>
</asp:Repeater>

答案 1 :(得分:0)

style="width:20px;"代替width="20px"

相关问题