This is a migrated thread and some comments may be shown as answers.

RadListView and RSSFeed Live demo

1 Answer 42 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 03 Dec 2012, 02:37 PM
Hi,

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?

Thanks.

/Thomas

<telerik:RadListView ID="RadListView1" runat="server" OnNeedDataSource="RadListView1_NeedDataSource"
    AllowPaging="true" ItemPlaceholderID="Panel1" PageSize="3">
    <LayoutTemplate>
        <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>
                <div class="rssHeader">
                    rss <span class="rssHeadingDate">
                        <%# DateTime.Now.ToLongDateString().ToLower() %></span>
                </div>
            </div>
            <br />
            <asp:Panel ID="Panel1" runat="server">
            </asp:Panel>
            <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" />
            </div>
        </div>
    </LayoutTemplate>
    <ItemTemplate>
        <table class="rssTable" title='Item <%# (Container as RadListViewDataItem).DataItemIndex %>, Page <%# RadListView1.CurrentPageIndex + 1 %>'
            style="vertical-align: top;">
            <tr>
                <td>
                      
                </td>
                <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 %>
                        </a>
                    </div>
                    <div class="rssDate">
                        <%# (Container.DataItem as XmlNode)["pubDate"].InnerText %>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                      
                </td>
                <td>
                    <img style="border: solid 1px #999" src='<%# (Container.DataItem as XmlNode)["hww:photo"].InnerText %>'
                        alt='<%# (Container.DataItem as XmlNode)["title"].InnerText %>' />
                </td>
                <td>
                    <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>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</telerik:RadListView>

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 06 Dec 2012, 11:54 AM
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:
http://www.telerik.com/help/aspnet-ajax/listview-accessing-controls.html

All the best,
Vasil
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.
Tags
ListView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or