Atlantiz8
Atlantiz8

Reputation: 65

html table <td> width in repeater itemtemplate unable to set

I'm trying to adjust the width of the columns in the HTML table which act as the holder of ASP repeater items.

<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>

Notice that the header follows the width, but the content does not. WHY? Here's how my table looks like currently:

Upvotes: 1

Views: 11120

Answers (2)

Rahul
Rahul

Reputation: 5636

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>

Upvotes: 2

jishnu saha
jishnu saha

Reputation: 165

Put style="width:20px;" instead of width="20px"

Upvotes: 0

Related Questions