Nesting a repeater inside a table??

  • Thread starter Thread starter mj.redfox.mj
  • Start date Start date
M

mj.redfox.mj

Hi

I'm fairly new to ASP.NET and realise I'm probably asking a very
straightforward question, sorry about that but I'd be grateful if
someone could possibly help out - I'm sure the answer will turn out to
be very easy!


I'm trying to basically do the following (in reality there is a lot
more code in between the table rows, such as the cells and their
contents, but I'm only posting the structure here as that's the
relavant bit):


<asp:Table>

<asp:TableRow>
</asp:TableRow>

<asp:TableRow>
</asp:TableRow>

<asp:TableRow>
</asp:TableRow>

<asp:Repeater ID="rep1" runat="server">
<ItemTemplate>
<asp:TableRow>
</asp:TableRow>
</ItemTemplate>
</asp:Repeater>

</asp:Table>


Unfortunately, the parser doesn't like the repeater being where it is
- however I definitely need to use a repeater here, as I've got some
other non-repeating stuff to include in the first few table rows (a
basic data grid with just one header row wouldn't even begin to
accommodate what I need for this). If anyone could suggest how I can
get the above code to compile I'd be very grateful!
 
I think I MAY have found the answer...I believe I need to use the
Repeater's <headertemplate> fof the non-repeating rows. Will post
again once I've tested this.
 
Hi again

A quick update...sadly that didn't work. I felt sure this would solve
my problem...


<asp:Repeater ID="rep1" runat="server">
<headertemplate>
<asp:Table>

<asp:TableRow>
</asp:TableRow>

<asp:TableRow>
</asp:TableRow>

<asp:TableRow>
</asp:TableRow>

</headertemplate>
<ItemTemplate>

<asp:TableRow>
</asp:TableRow>
</ItemTemplate>

<ItemTemplate>

<FooterTemplate>
</asp:Table>
</FooterTemplate>

</asp:Repeater>


....but I get the following error...


System.Web.UI.WebControls.TableRowCollection must have items of type
'System.Web.UI.WebControls.TableRow'. 'ItemTemplate' is of type
'System.Web.UI.HtmlControls.HtmlGenericControl'


I'll keep trying to solve this and report back with any progress!
 
Oops, ignore the last <ItemTemplate> above, I know that shouldn't be
there. Apologies.
 
Back
Top