Reputation: 2899
I have a webapp that goes and makes some webgets and returns the results in Gridview
. Sometimes, the app may need to make 400+ webgets, but only populate the grid with 15-20 records.
Is there a way to partially load a GridView
, so that each record is appended to the existing GridView
?
Adding Code
List<Test> testList = new List<Test>();
foreach (Location str in list)
{
string url;
try
{
url = "http://www.test.com/" + str.Url;
XmlReader reader = XmlReader.Create(url);
Rss10FeedFormatter formatter = new Rss10FeedFormatter();
if (formatter.CanRead(reader))
{
formatter.ReadFrom(reader);
IEnumerable<SyndicationItem> items = formatter.Feed.Items;
int itemCt = 1;
foreach (SyndicationItem item in items)
{
Test test = new Test();
test.Name = item.Name;
test.City= item.City;
testList.Add(data);
//if I add this here, the RowDatabound does not fire, if I take out, it works fine but only after all requests are made
listGrid.DataSource = temp;
listGrid.DataBind();
}
}
else
throw new ApplicationException("Invalid RSS 1.0 feed at " + FeedUrl.Text.Trim());
}
Upvotes: 1
Views: 77
Reputation: 3526
Create a separate list that you will DataBind the gridview to, and then whenever you change the elements in that list just rebind the gridview.
var mySmallerList = bigList.Skip(someNumber).Take(someOtherNumber);
myGridView.DataSource = mySmallerList;
Upvotes: 1