Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Repeater problems

  Asked By: Kaua    Date: Dec 09    Category: Asp.net    Views: 1563
  

I am having a problem with Repeaters. I have a table that I want to fill with
some data from my database. I have created the bacis structure for the table
and the repeater. It looks like this:


<asp:Repeater id="test" runat="server">


<HeaderTemplate><table border="1" width="100%"><tr><td></td>


</tr></HeaderTemplate>

<ItemTemplate><tr><td><%#Container.DataItem("")%></td><td><%#Container.DataItem(\
"")%></td><td><%#Container.DataItem("")%></td><td><%#Container.DataItem("")%></t\
d><td><%#Container.DataItem("")%></td><td><%#Container.DataItem("")%></td></tr><\
/ItemTemplate>

<FooterTemplate></table></FooterTemplate>

</asp:Repeater>

The 'table' element has a line under it indicating an error, when I put my
cursor

over it it says: the element 'table' is missing its closing tag or overlaps

with element 'HeaderTemplate'. what am I doing wrong here?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Chung Tran     Answered On: Dec 09

If a tag  is nested within another tag, in your case you have started
<HeaderTemplate> and then <TABLE......>, then the nested tag needs to be closed
before the nesting tag. You need to add </TABLE> before your </HeaderTemplate>

 
Answer #2    Answered By: Salvador Alexander     Answered On: Dec 09


<asp:Repeater id=Repeater1 runat="server">
<HeaderTemplate>
<table border=1>
<tr>
<td><b>Company</b></td>
<td><b>Symbol</b></td>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
<td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>

is straight from MSDN.NET ... maybe it doesn't like your html on the same line
as its <template> ?

 
Answer #3    Answered By: Andrew Bryant     Answered On: Dec 09

Nothing. The thing is that design time VS.NET checks for obvious html errors. It
checks for correctness of html tags and which one can (by specification) include
which elements... So a table  definitely doesn't permit anything else than tr,
tbody and maybe something else. repeater  or header template or other exotic
elements are definitely not permitted. The thing is that when you save your page
it will work correctly and you won't get any runtime error. And in fact the page
will also compile correctly without any errors.

Actually I hate VS.NET for these problems. It deletes code, it changes styles
and things like that. I hate that, so I disabled all this to make it at least
usable. I rather write my complex tables than draw them inside designer...

Maybe just a hint. Inside your header put  only Table element  no TRs or TDs.
Actually you're making by specification a not error-free table. Each row should
incorporate same number of cells.

You could also ommit header and footer templates if you put TABLE outside
repeater... Maybe the design error  won't happen. and your repeater won't have
any header and footer which will execute faster.

 
Didn't find what you were looking for? Find more on Repeater problems Or get search suggestion and latest updates.




Tagged: