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
     
    JB, Oct 23, 2009
    #1
    1. Advertising

  2. Re: How to force Repeater control formatting <td width> and line bre

    On Oct 23, 11:29 pm, JB <> wrote:
    > 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


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

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    850
    Bruce Barker
    Oct 10, 2005
  2. Ganesh
    Replies:
    0
    Views:
    596
    Ganesh
    Nov 16, 2007
  3. Replies:
    0
    Views:
    515
  4. Digit24

    repeater control: conditional formatting

    Digit24, Dec 21, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    269
    Digit24
    Dec 21, 2005
  5. bernadou

    Force multi line field value to output with line breaks?

    bernadou, Jan 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    395
    bernadou
    Jan 23, 2006
Loading...

Share This Page