RadListView and RSSFeed Live demo

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    14 posts
    Member since:
    Mar 2012

    Posted 03 Dec 2012 Link to this post


    I've used a part of the code from the RSSFeed Live demo in my own web user control.
    When the RSS source isn't available the RSS reader fails.

    How can I handle errors in loading the RSS feed so it won't make the application crash, and also, how can I set the text for the prev and next buttons from code behind?



    <telerik:RadListView ID="RadListView1" runat="server" OnNeedDataSource="RadListView1_NeedDataSource"
        AllowPaging="true" ItemPlaceholderID="Panel1" PageSize="3">
            <div class="layoutWrapper">
                <div class="rssHeaderWrapper" title="Copyright, 2011 Honda Motor Co., Ltd. and its subsidiaries and affiliates. All Rights Reserved.">
                    <div class="rssSubHeader">
                        honda world news
                    <div class="rssHeader">
                        rss <span class="rssHeadingDate">
                            <%# DateTime.Now.ToLongDateString().ToLower() %></span>
                <br />
                <asp:Panel ID="Panel1" runat="server">
                <div style="width: 100%; text-align: center;">
                    <asp:ImageButton ID="PrevBtn" runat="server" CommandName="Page" CommandArgument="Prev"
                        AlternateText="<" CssClass="rssButtons" ImageUrl="images/iconPrev.png" />
                    <asp:ImageButton ID="RefreshBtn" runat="server" CommandName="Rebind" AlternateText="Refresh"
                        CssClass="rssButtons" ImageUrl="images/iconRefresh.png" />
                    <asp:ImageButton ID="NextBtn" runat="server" CommandName="Page" CommandArgument="Next"
                        AlternateText=">" CssClass="rssButtons" ImageUrl="images/iconNext.png" />
            <table class="rssTable" title='Item <%# (Container as RadListViewDataItem).DataItemIndex %>, Page <%# RadListView1.CurrentPageIndex + 1 %>'
                style="vertical-align: top;">
                    <td colspan="2">
                        <div class="rssTitle">
                            <img src="images/iconRSS.png" alt="rss" />
                            <a href='<%# (Container.DataItem as XmlNode)["link"].InnerText %>' class="qsfSubtitle">
                                <%# (Container.DataItem as XmlNode)["title"].InnerText %>
                        <div class="rssDate">
                            <%# (Container.DataItem as XmlNode)["pubDate"].InnerText %>
                        <img style="border: solid 1px #999" src='<%# (Container.DataItem as XmlNode)["hww:photo"].InnerText %>'
                            alt='<%# (Container.DataItem as XmlNode)["title"].InnerText %>' />
                        <img src='<%# (Container.DataItem as XmlNode)["hww:flag"].InnerText %>' alt='<%# (Container.DataItem as XmlNode)["hww:flag"].InnerText %>' />
                        <span class="rssDescription">
                            <%# (Container.DataItem as XmlNode)["description"].InnerText %></span>
  2. Vasil
    Vasil avatar
    1604 posts

    Posted 06 Dec 2012 Link to this post

    Hello Thomas,

    In the code behind wrap the doc.Load(rssUrl); inside Try-Catch statement, to handle the case when the RSS is not available.
    See this help topic about accessing controls inside the ListView:

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top