• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

ASP.NET 2 Column Table

Robizzle01

Limp Gawd
Joined
Sep 30, 2005
Messages
159
I'm currently displaying a table of items using a repeater and each table row has only a single column or td. I would like to make it a two column table like how the Photos application on Facebook displays albums.

Basically what I have right now is
<table>
<tr><th>Items</th></tr>
<tr><td>Item 1</td></tr>
<tr><td>Item 2</td></tr>
<tr><td>Item 3</td></tr>
<tr><td>Item 4</td></tr>
etc...
</table>

And what I want to have is
<table>
<tr><th>Items</th></tr>
<tr><td>Item 1</td><td>Item 2</td></tr>
<tr><td>Item 3</td><td>Item 4</td></tr>
etc....
</table>

However, using repeaters I am only able to specify a Header, ItemTemplate, AlternatingItemTemplate and Footer. The closest I could do is

<asp:Repeater ID="rItems" runat="server">
<HeaderTemplate><table><tr><th>Items</th></tr></HeaderTemplate>
<ItemTemplate><tr><td>[Odd Numbered Item Data Here]</td></ItemTemplate>
<AlternatingItemTemplate><td>[Even Numered Item Data Here]</td></tr></AlternatingItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>

However, the above hack will only work if there are an even number of items. If there are an odd number of items, then the final AlternatingItemTemplate will not be called which will leave a <tr> open without a closing </tr>.

The only other way I could think to accomplish what I want is to build a string of html the way I want in the codebehind; however, this is clearly undesirable. Especially since I want to have enough flexibility that a designer could change the aspx page without having to touch anything in the code behind.
 
I have read through both of those articles several times now (a little difficult with all the new terminology) and wasn't able to think of a way to apply them to my problem. Any suggestions on what I need to look into specifically would help greatly.
 
Back
Top