Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Repeater Control - formatting columns problem

Repeater Control - formatting columns problem

Scheduled Pinned Locked Moved ASP.NET
htmlsysadminhelpannouncement
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Richard Blythe
    wrote on last edited by
    #1

    I'm using a Repeater to display a list of events. Here's a stripped down version of the code:

    <asp:Repeater ID="rptEvents" runat="server">
    <ItemTemplate>
    <table style="width: 100%" border="1">
    <tr>
    <td style="width: 180px; white-space: nowrap;">
    <img align="middle" alt="Events" src="images/thumbnail.png" style="width: 50px; height: 51px" />
    <asp:Label ID="lblEventName" runat="server"></asp:Label>
    </td>
    <td>
    <asp:Label ID="lblDescription" runat="server"></asp:Label>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:Repeater>

    Notice that the first column has been set to "white-space: nowrap" so that longer event names will push the column to be wider. Here's some sample html that the Repeater would generate:

    <table style="width: 100%" border="1">
    <tr>
    <td style="width: 100px; white-space: nowrap;">
    <img align="middle" alt="Events" src="thumbnail.png" />
    <span id="rptEvents_ctl00_lblEventName">New Products Overview</span>
    </td>
    <td>
    <span id="rptEvents_ctl00_lblDescription">Showcases the new products the will be released this year.</span>
    </td>
    </tr>
    </table>

    <table style="width: 100%" border="1">
    <tr>
    <td style="width: 100px; white-space: nowrap;">
    <img align="middle" alt="Events" src="thumbnail.png" />
    <span id="rptEvents_ctl01_lblEventName">Supervisor Planning Meeting</span>
    </td>
    <td>
    <span id="rptEvents_ctl01_lblDescription">All supervisors must be present.</span>
    </td>
    </tr>
    </table>

    <table style="width: 100%" border="1">
    <tr>
    <td style="width: 100px; white-space: nowrap;">
    <img align="middle" alt="Events" src="thumbnail.png" />
    <span id="rptEvents_ctl02_lblEventName">Holiday Weekend</span>
    </td>
    <td>
    <span id="rptEvents_ctl02_lblDescription">The company will close for the week of Christmas.</span>
    </td>
    </tr>
    </table>

    If and when that occurs, I want the first column in each repeater item to be the same width as the column with the longest event name. How can

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups