How to force Repeater control formatting <td width> and line bre

Discussion in 'ASP .Net' started by JB, Oct 23, 2009.

  1. JB

    JB Guest

    Hello

    In my ASP.NET web application I am using the Repeater control. Placed
    the Repeater in a Panel Control and included it in a table in order to make
    data print one row on each line across the page, the datasource is a
    DataTable and I am using css. I use a HeaderTemplate to create column
    headings then I use ItemTemplate to show the data in the columns. The
    problem is that the first row does use the width formatting that I
    specified in the <td> tag and therefore prints under the column headings
    the way that it should but the remaining rows in the table ignore the width
    formatting that I specified in the <td> tag and just prints the rows using
    its default setting which stops the rows data from continuing to print
    under its corresponding column heading also none of the rows print on a
    separate line so I inserted a <br /> tag to force a line break but I don't
    think you are supposed to need to do that. So my questions are:

    How do you make all rows in the table print using the width formatting
    in the <td> tag and whether or not you must use <br /> to force line
    breaking like I am doing?

    Note: None of the examples that I have seen used <br /> but I know some
    html so I used it to force the lines to break.

    Below is the code:

    <asp:panel ID="pnlIncident" runat="server">
    <asp:Repeater ID="rptIncident" runat="server">

    <HeaderTemplate>
    <table >
    <tr>
    <th align="left" width="40px">Prob#</th>
    <th align="left" width="45px">Type</th>
    <th align="left" width="40">p1</font></th>
    <th align="left" width="45">p2</font></th>
    </tr>
    </HeaderTemplate>

    <ItemTemplate>
    <tr>
    <td align="left" width="40px" ><%#

    DataBinder.Eval(Container.DataItem, "Prob#") %></td>
    <td align="left" width="45px"> <%#

    DataBinder.Eval(Container.DataItem, "Type") %></td>
    <td align="left" width="40px" ><%#

    DataBinder.Eval(Container.DataItem, "p1") %></td>
    <td align="left" width="45px"> <%#

    DataBinder.Eval(Container.DataItem, "p2") %></td>
    </tr>
    <br />

    </table>
    </ItemTemplate>

    </asp:Repeater>
    </asp:panel>

    JB
     
    JB, Oct 23, 2009
    #1
    1. Advertisements

  2. Try to use style="width:xx" instead of width attribute. I think, you
    don't need to repeat it for TD cells and you can use style only for
    TH. Note, that

    <th align="left" width="40">p1</font></th>
    <th align="left" width="45">p2</font></th>

    has </font> in the cells...

    I don't get what does <br /> in your code, but this would definitely
    cause validation error
     
    Alexey Smirnov, Oct 24, 2009
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.