Link to home
Start Free TrialLog in
Avatar of deecree
deecree

asked on

Datalist produces extra <tr><td></td></tr>

Hi,

I have an ASCX control with a Datalist inside. This datalist only defines a <headerTemplate> and <ItemTemplate>
and in each, the markup for a single table row.
When rendered it instead produces an extra table row rather than only the one I defined. How do I fix this?

See below:

 UNRENDERED HTML
--------------------------
<asp:DataList ID="dlCategories" runat="server" CellSpacing="0" CellPadding="3" Width="100%">
    <HeaderTemplate>
        <tr>
            <td class="moduletitles" colspan="2">
                Categories
            </td>
        </tr>
        <tr>
            <td class="modulelinks">
                   <asp:HyperLink CssClass="modulelinks" ID="hpCategories" NavigateUrl="~/default.aspx" runat="server">All</asp:HyperLink>
            </td>
            <td class="modulelinks" align="right">
            <asp:HyperLink ID="hpRSS" runat="server" NavigateUrl="~/rss.aspx" ImageUrl="~/webfeed.gif"></asp:HyperLink></td>
        </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td class="modulelinks">
                    &nbsp;&nbsp;<asp:HyperLink CssClass="modulelinks" ID="hplCategories" NavigateUrl='<%# "~/category.aspx?c=" + DataBinder.Eval(Container.DataItem, "CategoryID") %>' runat="server"><%# DataBinder.Eval(Container.DataItem, "CategoryName") %></asp:HyperLink>
            </td>
            <td class="modulelinks" align="right">
                <asp:HyperLink ID="hplRSS" runat="server" NavigateUrl='<%# "~/rss.aspx?c=" + DataBinder.Eval(Container.DataItem, "CategoryID") %>' ImageUrl="~/webfeed.gif"></asp:HyperLink>
            </td>
        </tr>
    </ItemTemplate>
</asp:DataList>


================

RENDERED IN BROWSER ( * - marks unwanted and undefined rows )
------------------------------

<table id="categorymodule_dlCategories" style="width: 100%; border-collapse: collapse;" border="0" cellpadding="3" cellspacing="0">
      <tbody>

        *<tr>
            <td>
        </td></tr>*

        <tr>

            <td class="moduletitles" colspan="2">
                Categories
               
            </td>
        </tr>
        <tr>
            <td class="modulelinks">
                    &nbsp;&nbsp;<a id="categorymodule_dlCategories_ctl00_hplCategories" class="modulelinks" href="default.aspx">All</a>
            </td>

            <td class="modulelinks" align="right">
            <a id="categorymodule_dlCategories_ctl00_hpRSS" href="rss.aspx"><img src="webfeed.gif" style="border-width: 0px;"></a></td>
        </tr>
   
      <tr>
            <td>
        </td></tr><tr>
            <td class="modulelinks">
                    <a id="categorymodule_dlCategories_ctl01_hpCategories" class="modulelinks" href="category.aspx?c=1">General</a>

            </td>
            <td class="modulelinks" align="right">
                <a id="categorymodule_dlCategories_ctl01_hplRSS" href="rss.aspx?c=1"><img src="webfeed.gif" style="border-width: 0px;"></a>
            </td>
        </tr>
   
      *<tr>
            <td>
        </td></tr>*
       
        <tr>
            <td class="modulelinks">

                    &nbsp;&nbsp;<a id="categorymodule_dlCategories_ctl02_hpCategories" class="modulelinks" href="category.aspx?c=2">Cuzco</a>
            </td>
            <td class="modulelinks" align="right">
                <a id="categorymodule_dlCategories_ctl02_hpRSS" href="rss.aspx?c=2"><img src="webfeed.gif" style="border-width: 0px;"></a>
            </td>
        </tr>
   
      
</tbody></table>

ASKER CERTIFIED SOLUTION
Avatar of HappyFunBall
HappyFunBall

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deecree
deecree

ASKER

Yes, you seem to be right. I guess the repeater will do.
Thanks.