using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data;
namespace ZimmergrenRssFeed.ZimmergrenRssFeed
{
[ToolboxItemAttribute(false)]
public class ZimmergrenRssFeed : WebPart
{
DataSet dset;
SPGridView sgvRssFeed;
protected override void Render(HtmlTextWriter writer)
{
sgvRssFeed.RenderControl(writer);
}
protected override void CreateChildControls()
{
sgvRssFeed = new SPGridView();
sgvRssFeed.AutoGenerateColumns = false;
sgvRssFeed.DataMember = "item";
HyperLinkField hlnk = new HyperLinkField();
hlnk.DataNavigateUrlFields = new string[] { "link" };
hlnk.HeaderText = "Title";
hlnk.DataTextField = "Title";
sgvRssFeed.Columns.Add(hlnk);
BoundField bDesc = new BoundField();
bDesc.HeaderText = "Description";
bDesc.DataField = "description";
sgvRssFeed.Columns.Add(bDesc);
this.Controls.Add(sgvRssFeed);
sgvRssFeed.DataSource = GetTimesofIndiaRss();
sgvRssFeed.DataBind();
}
public DataSet GetTimesofIndiaRss()
{
string strRss = "http://www.zimmergren.net/rss.xml";
dset = new DataSet();
dset.ReadXml(strRss);
return dset;
}
}
}
No comments:
Post a Comment