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

Discussion in 'ASP .Net' started by mj.redfox.mj, Mar 1, 2007.

  1. mj.redfox.mj

    mj.redfox.mj Guest

    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.
     
    mj.redfox.mj, Mar 1, 2007
    #1
    1. Advertisements

  2. mj.redfox.mj

    Aidy Guest

    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.
     
    Aidy, Mar 1, 2007
    #2
    1. Advertisements

  3. mj.redfox.mj

    mj.redfox.mj Guest

    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">?
     
    mj.redfox.mj, Mar 1, 2007
    #3
  4. mj.redfox.mj

    Aidy Guest

    I use the repeater;

    <HeaderTemplate>
    <table>
    </HeaderTemplate>

    <ItemTemplate>
    <tr>

    </tr>
    </ItemTemplate>

    <FooterTemplate>
    </table>
    </FooterTemplate>
     
    Aidy, Mar 1, 2007
    #4
  5. mj.redfox.mj

    Russell Guest

    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?
     
    Russell, Mar 2, 2007
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.