Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

Binding RssFeed To a Dynamic GridView in Asp.Net

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default4 : System.Web.UI.Page
{
GridView dgvRssFeed;
DataSet dset;
protected void Page_Load(object sender, EventArgs e)
{
dgvRssFeed = new GridView();
dgvRssFeed.ID = "dgvRssFeed";
dgvRssFeed.AutoGenerateColumns = false;
dgvRssFeed.DataMember = "item";
HyperLinkField hlnk = new HyperLinkField();
hlnk.DataNavigateUrlFields = new string[] { "link" };
hlnk.HeaderText = "Title";
hlnk.DataTextField = "Title";
dgvRssFeed.Columns.Add(hlnk);
BoundField bDesc = new BoundField();
bDesc.HeaderText = "Description";
bDesc.DataField = "description";
dgvRssFeed.Columns.Add(bDesc);
this.form1.Controls.Add(dgvRssFeed);
if (!IsPostBack)
{
dgvRssFeed.DataSource = GetTimesofIndiaRss();
dgvRssFeed.DataBind();
}
}
public DataSet GetTimesofIndiaRss()
{
string strRss = "http://timesofindia.indiatimes.com/rssfeedstopstories.cms";
dset = new DataSet();
dset.ReadXml(strRss);
return dset;
}
}

No comments:

Post a Comment