Repeater Control - formatting columns problem
-
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