Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Bind RSS Feeds to Repeater Control

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 175
    Comment on it

    Hi All,

    RSS feeds are the Rich Site Summary feeds, benefit users who want to receive timely updates from favorite websites or to aggregate data from many sites. Here i am using ABC News RSS feeds to get the news Update. A particular RSS feeds are only available if they are provided by the site.

    Firstly we will add a Aspx file in our project file then add a repeater control in it or copy paste following code :-

     <asp:Repeater ID="rptrRssControl" runat="server">
                    <HeaderTemplate>
                        <table border="0" width="80%" cellpadding="2" cellspacing="1" style="border: 1px solid maroon;">
                            <tr bgcolor="maroon">
                                <th style="color:white">Title</th>
                                <th style="color:white">Link</th>
                                <th style="color:white">description</th>
                                <th style="color:white">Published Date</th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td width="20%">
                                <%# DataBinder.Eval(Container, "DataItem.title")%>
                            </td>
                            <td width="20%">
                                <%# DataBinder.Eval(Container, "DataItem.link")%>
                            </td>
                            <td width="20%">
                                <%# DataBinder.Eval(Container, "DataItem.description")%>
                            </td>
                            <td width="20%" align="center">
                                <%# DataBinder.Eval(Container, "DataItem.pubdate")%>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <AlternatingItemTemplate>
                        <tr bgcolor="#e8e8e8">
                            <td width="20%">
                                <%# DataBinder.Eval(Container, "DataItem.title")%>
                            </td>
                            <td width="20%">
                                <%# DataBinder.Eval(Container, "DataItem.link")%>
                            </td>
                            <td width="20%">
                                <%# DataBinder.Eval(Container, "DataItem.description")%>
                            </td>
                            <td width="20%" align="center">
                                <%# DataBinder.Eval(Container, "DataItem.pubdate")%>
                            </td>
                        </tr>
                    </AlternatingItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>

     

    Then on code behind add the following code on page load event :-

     try
                {     
                    //Create a new DataSet
                    DataSet ds = new DataSet();
    
                    //Read the Response into the DataSet
                    ds.ReadXml("http://feeds.abcnews.com/abcnews/topstories");
    
                    //Bind the Results to the Repeater
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        rptrRssControl.DataSource = ds.Tables[3];
                        rptrRssControl.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }

    The out put will be like :-

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: