Reputation: 6056
I have a GirdView which has more than thousands of records binded to it. I have applied the Paging for GirdView whenever we traverse the paging the request is sent again to Server and whole data is loaded into GridView from SQLServer DB, which I want to avoid Server Round Trip. Is it possible to Load Data First 100 Number of Records and then 101 to 200 and so on..Records when Scrolling the Grid or Paging from DataTable or DataSet?
Similar to Facebook loads Data on the Page only when the User Scrolls down the page. Is it possible to do in ASP.NET using C#?
Please Give me suggestion
Upvotes: 1
Views: 8858
Reputation: 11
Convert DataTable to json format :
public static string DataTableToJSON(DataTable table)
{
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
foreach (DataRow row in table.Rows)
{
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (DataColumn col in table.Columns)
{
dict[col.ColumnName] = row[col];
}
list.Add(dict);
}
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(list);
}
Upvotes: 1
Reputation: 697
Use Custom paging for the purpose and while fetching the data from the database use skip and take in your query.
Upvotes: 0
Reputation: 6959
Yes it is possible however fairly convoluted. You may be better off using one of the Javascript model binding frameworks (Backbone/KnockoutJs) to implement this.
If you do want to however, you'd need to put your GridView inside an UpdatePanel and then listen to the window scroll event in Javascript and each time the event is fired rebind the GridView datasource.
Upvotes: 0