CodeSmith Community
Your Code. Your Way. Faster!

Strongly typed repeater

rated by 0 users
This post has 6 Replies | 2 Followers

Top 75 Contributor
Posts 82
Points 2,058
Rippo Posted: 02-14-2008 9:31 AM

Has anyone else having troubles with strong typed repeaters and the way the HTML code is outputted

for example

<table class="table">
<data:allrepositoryrepeater id="RepList" runat="server" enableviewstate="false" datasourceid="ds1">
    <itemtemplate>
        <tr class="odd">
            <td><%#Container.Title %></td>
        </tr>
    </itemtemplate>
</data:allrepositoryrepeater>
</table>

outputs

<table class="table">
<span id="ctl00_MainContentPlaceHolder_RepList">
<tr class="odd">
<td>Test</td>
</tr>
<tr class="odd">
<td>Test2</td>
</tr>
</span>
</table>

As you can see a weird span is inserted? Is this a know bug or does strongly type repeaters not support HTML tables?


 

 

 

 

Richard Wilde wildesoft.net

Top 75 Contributor
Posts 82
Points 2,058

Bumpty bump... 

Richard Wilde wildesoft.net

  • | Post Points: 5
Top 50 Contributor
Posts 106
Points 2,010

I think this is because the strongly typed repeater controls inherit from System.Web.UI.Design.ControlDesigner.  This is by design, I believe, as someone may not necessarily want to use a table to output their data.

If you want to use a table, you could add the appropriate table tags to the HeaderTemplate and FooterTemplate.

I'm outside ur box, shiftin' ur paradigm.
  • | Post Points: 35
Top 75 Contributor
Posts 82
Points 2,058

The header and footer templates do not output anything and are completely ignored! The span attribute is ouputed regardless. This used to work fine a few months ago on old templates but obviously a change to the templates has caused this problem. 

This leaves the repeater useless for tabular data. 

Richard Wilde wildesoft.net

  • | Post Points: 35
Top 50 Contributor
Posts 106
Points 2,010

You are correct, and I have egg on my face.
Sounds like a serious bug here.... I'm debugging through the code, and it seems to add the controls... but I'm no expert with the ComponsiteDataBoundControl...

I'm outside ur box, shiftin' ur paradigm.
  • | Post Points: 5
Top 50 Contributor
Posts 106
Points 2,010

I was able to "fix" this by moving the code that adds the Header and Footer as controls from the CreateChildControls() method to the CreateChildControls(IEnumerable datasource, bool databinding) method (before and after the foeach) in the respective EntityRepeater classes.

This, however, caused a <span> tag to surround the <table> tags.....

I'm going to look in to this some more and get back with you.

I'm outside ur box, shiftin' ur paradigm.
  • | Post Points: 5
Top 50 Contributor
Posts 106
Points 2,010

I've posted a patch that fixes this here:

http://community.codesmithtools.com/forums/p/8181/30188.aspx#30188

Let me know if this works for you... I'm not sure if this will break other things.

I'm outside ur box, shiftin' ur paradigm.
  • | Post Points: 5
Page 1 of 1 (7 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems