我有一个应用程序,我想从应用程序下载不同用户的推文:
DataTable dt = obj.GetTableSP("GetAllBioOrderByNewest");
foreach (DataRow dr in dt.Rows)
{
WebClient wb = new WebClient();
Uri myUri = new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?include_entities=true&include_rts=true&count=10&screen_name=" + dr["TwitterHandle"].ToString());
wb.DownloadStringAsync(myUri);
wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wblastID_DownloadStringCompleted);
}
在这里我如何在gridview中绑定结果:
public void wblastID_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs args)
{
try
{
XElement xmlTweets = XElement.Parse(args.Result);
GridView1.DataSource = (from tweet in xmlTweets.Descendants("status")
select new Tweet
{
ID = tweet.Element("id").Value,
Message = tweet.Element("text").Value,
UserName = tweet.Element("user").Element("screen_name").Value,
TwitTime = tweet.Element("created_at").Value
}).ToList();
GridView1.DataBind();
if (GridView1.Rows.Count < 10)
{
viewmore.Visible = false;
}
}
catch
{
MessageBox.Show("Error downloading tweets");
}
}
但这里的问题是,我只从数据表中获取最后一个用户的推文。
我想要的是,所有用户的组合结果dt
并将其显示在 gridview 中。