Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6472539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:21:25+00:00 2026-05-25T06:21:25+00:00

I have the following code. It works as is, but… I am not always

  • 0

I have the following code. It works as is, but… I am not always going to have an even number of items in the RSS feed So, at the end of the table, I might have only one table cell on the last row. So, is there a way to count the number of ItemTemplates and AlternatingItemTemplate, so if it is an odd number I would be able to add another cell <td>&nbsp;</td></tr> and close the table row?

<asp:XmlDataSource ID="SomeFeed" DataFile="TestSomeRSS.xml" XPath="rss/channel/item" runat="server"></asp:XmlDataSource>

<asp:ListView ID="SomeFeedScroller" DataSourceID="SomeFeed" ItemPlaceholderID="SomePlcID" runat="server">

<LayoutTemplate>

<table id="ListingsTable" cellpadding="0" cellspacing="0" align="center">
    <asp:PlaceHolder ID="SomePlcID" runat="server"></asp:PlaceHolder>
</table>

</LayoutTemplate>

<ItemTemplate>
    <tr style="vertical-align:top;">
    <td class="bnotes" style="width:325px;padding:5px;">
        <%# XPath("title")%><br />
        <%# XPath("description")%><br />
    </td>
</ItemTemplate>

<AlternatingItemTemplate>
    <td class="bnotes" style="width:325px;padding:5px;">
        <%# XPath("title")%><br />
        <%# XPath("description")%><br />
    </td>
    </tr>
</AlternatingItemTemplate>

</asp:ListView>

Thanks in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:21:25+00:00Added an answer on May 25, 2026 at 6:21 am

    I’m not sure what you’re asking, but why not just put a complete row in the ItemTemplate and AlternatingItemTemplate, like this:

    <ItemTemplate>
        <tr style="vertical-align:top;">
            <td class="bnotes" style="width:325px;padding:5px;">         
                <%# XPath("title")%><br />         
                <%# XPath("description")%><br />     
            </td>
        </tr> 
    </ItemTemplate>  
    <AlternatingItemTemplate>
        <tr style="vertical-align:top;">     
            <td class="bnotes" style="width:325px;padding:5px;">         
                <%# XPath("title")%><br />         
                <%# XPath("description")%><br />     
            </td>     
        </tr> 
    </AlternatingItemTemplate>
    

    That way you don’t have to figure it out yourself – just let the control render itself.

    EDITED TO ADD

    Looking at your posted code again, it looks like you might have been attempting one row of alternating cell styles. I think you misunderstood the intent of the ItemTemplate and AlternatingItemTemplates; they usually deal with the fields (columns) of a given record.

    In this case, you’d have the first RSS feed item in an ItemTemplate, then the second RSS feed item in an AlternateItemTemplate (i.e., another row), then the third RSS feed item in an ItemTemplate and so on.

    I hope this helps – if I’ve misunderstood what you’re trying to do let me know.

    2nd Edit

    Based on the example layout posted in the comments, I think the DataList Class would be a better option, as you can easily specify multiple columns (using the RepeatColumns property). Something like this:

    <asp:XmlDataSource ID="SomeFeed" DataFile="TestSomeRSS.xml" XPath="rss/channel/item" runat="server">
    </asp:XmlDataSource>
    
    <asp:DataList ID="SomeFeedScroller" DataSourceID="SomeFeed" 
                  RepeatColumns="2" RepeatDirection="Horizontal" 
                  RepeatLayout="Table" runat="server">
        <ItemStyle CssClass="bnotes" Vertical-Align="top" Width="325px" />
        <AlternatingItemStyle CssClass="bnotes" vertical-Align="top" Width="325px" />
        <ItemTemplate>
            <%# XPath("title")%><br />
            <%# XPath("description")%>
        </ItemTemplate>
        <AlternatingItemTemplate>
            <%# XPath("title")%><br />
            <%# XPath("description")%>
        </AlternatingItemTemplate>
    </asp:DataList>
    

    The above is not tested, but the general idea was to keep the formatting as close to what was in the ListView as possible.

    Another possible approach might be something similar to this thread on having multiple columns in a Repeater control: Multiple columns in a repeater.

    The DataList control supports editing, selecting, updating, etc like ListView. The Repeater control does not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the following code. This code works sometime but sometime not works.
I have following code which works for radio buttons but need to be changed
I have the following code which works perfectly, but I want to allow access
I have the following code that works great for row click, but I want
I have the following code below which works, but I want to insert values
I have the following line of code which works fine locally, but breaks when
I have the following code, WHICH WORKS JUST FINE...WORKS AS I WANT. But if
I have following code which works fine in firefox and ie 8, but in
I have the following code that works well but I need a little more
I have the following code which works perfectly but I need an onblur statement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.