views:

197

answers:

3

Hi, I want to post my 5 recent twitters on my website. I've build a datagrid with XMLTextReader in C# which reads the feed but the problem I face is that it shows ALL the feeds and I can't find a way to only show 5. Any idea's?

        XmlTextReader reader = new XmlTextReader("http://some.rss/feed.rss");
        DataSet ds = new DataSet();
        ds.ReadXml(reader);
        dg.DataSource = ds.Tables[2];
        dg.AutoGenerateColumns = false;
        dg.AllowPaging = false;
        dg.DataBind();
+1  A: 

How about the simple solution of manually deleting all the rows from the DataTable except the first 5?

Vilx-
and how does one do that?
Erik404
Well, for example, like this: while ( dTbl.Rows.Count > 5 ) dTbl.Rows.RemoveAt(dTbl.Rows.Count-1);
Vilx-
+1  A: 

Better still, the Twitter API allows you to specify a "since ID" value. That way you can request only updates since the latest one you have.

Neil Barnwell
+2  A: 

to answer directly your question:

<asp:GridView ID="gv" runat="server"
              PageSize="5" AllowPaging="true">
   <PagerSettings Visible="false" />
</asp:GridView>

But I'm just wondering, why not trying to use a C# wrapper for Twitter API?

like:

http://devblog.yedda.com/index.php/2007/05/16/twitter-c-library/

or follow the fantastic post of Petar in

http://blogs.vertigo.com/personal/petar/Blog/archive/2008/06/23/twitter-wcf-client.aspx

P.S. add twitter to your tags!

balexandre
awesome! now thats an answer I can use, thanks mate!
Erik404