iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a webgrid with 30k rows. After a filtering it reduces to 500 rows. Now from server i would like to get these datarows together in a table or get the filtered data in a dataset or whatever possible as a form of datasource. How is it possible?
After filtering WebGrid, if the DataSource is DataTable, you will need to get the DataSource using GetCacheDataSource() method. This will return all the Row in the WebGrid. If you would like to retrieve the filtered row you will need to use the DataTable DefaultView property.
Here is the snippet:
((DataTable)[GridObject].GetCachedDataSource()).DefaultView
Thanks for the solution. It worked.
What if we can't use a DataTable? We have a WebGrid that uses an objectdatasource to retrieve about 90000 records. GetCacheDataSource returns nothing, and our project must use an objectdatasource.
Is there any way to get the filtered rows, server-side?
Thanks!
In order for the GetCachedDataSource to have a value, you will need to bind the data using InitializeDataSource server side event. Even if you are using ObjectDataSource, under such scenario, the GetCachedDataSource already returned the dataview object.
Here is the InitializeDataSource event handler:
protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e){ e.DataSource = ObjectDataSource1.Select();}
Glenn,
If I do that in the InitializeDataSource event handler, then I also have to add this to my PrepareDataBinding handler:
If (Not IsPostBack) Then WebGrid1.RetrieveStructure() End If
Doing that, however, causes the following error (on the RetrieveStructure line):
[NullReferenceException: Object reference not set to an instance of an object.] ISNet.WebUI.WebGrid.WebGrid.RetrieveStructure() +711
Brian
Testing the code using ObjectDataSource I also encounter the same issue. I am still discussing this issue with the developer. Currently, as a workaround you will need to bind the individual column manually similar to client binding scenario.
Based on my disucssion with the developer regarding this issue, for this scenario he suggest not to use the programmatic binding and GetCachedDataSource method. He suggest using binding the ObjectDataSource control ID to the WebGrid using the DataSourceID property.
In order to retrieve the filtered row count, you will need to use the RootTable rows count property if the grid is not using any paging. If the grid is using paging, you will need to retrieve the DataView rows count from one of the RootTable rows. Here is the snippet for the WebGrid with paging enabled:
int rowCount = 0;if(WebGrid1.RootTable.Rows.Count > 0){ rowCount = ((DataRowView)(WebGrid1.RootTable.Rows[0].DataRow)).DataView.Count;}
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname