Newbie needing help with a simple ASP.NET <table> problem...!

M

mj.redfox.mj

Hello, I'm hoping someone can help me out with a very basic problem
that's got me tearing my hair out! I'm wanting to have a repeater that
adds some rows to a table as below:


<asp:Repeater ID="repeater1" runat="server">

<HeaderTemplate>
<table id="table1" runat="server">
<tr>{header code goes here}</tr>
</HeaderTemplate>

<ItemTemplate>
<tr><td>
<asp:DropDownList ID="ddl1" runat="server">{drop-down list code goes
here}</asp:DropDownList>
</td></tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>


1. However, because of the 'runat="server"' in the table tag, this
throws an 'Unexpected end of file looking for </HeaderTemplate> tag'
error.

2. Removing the 'runat="server"' means that the code DOES compile -
however it seems to have the effect that whenever I try to do anything
with my drop-down list in the page-behind vb gives me a 'Object
reference not set to an instance of an object' error (not a problem
with the way I'm coding because the same line works fine in the vb if
the drop-down list is placed OUTSIDE of the table).

3. Also, the only other way I can think of to do this, to use an
<asp:table> instead (which was actually my preferred choice if I could
have got it working) gives a 'Server elements cannot span templates'
error.


Aaargghhh! There MUST be some way of having a repeater in a table as
above, AND allow server controls (that are actually useable) within
it. Can anyone help, as my head is sore from banging it against the
wall so much!

Many, many thanks indeed.
 
A

Aidy

Are you sure it's an error? I use this technique all the time, it does flag
up as a *warning*, but just ignore it.
 
M

mj.redfox.mj

Hi Aidy,

Thanks for replying. Can I just ask which of the three techniques you
use...
1. <asp:table>
2. <table>
or
3. <table runat = "server">?
 
A

Aidy

I use the repeater;

<HeaderTemplate>
<table>
</HeaderTemplate>

<ItemTemplate>
<tr>

</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>
 
R

Russell

Could it be that the problem is that the header template opens outside
the <table> tag and ends inside it? Could you move the opening table
tag below the header template?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top