This is a migrated thread and some comments may be shown as answers.

get all rows in grid

4 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DC
Top achievements
Rank 1
DC asked on 16 Mar 2010, 03:36 PM
Any suggestion on how I would access all the rows in the radgrid, not just the rows on page #1? I tried:

RadGrid1.MasterTableView.Items.Count

This gives me 10 rows because that is how many are listed per page but I need to get at the datatable source. The user has a search form that generates the grid. After the grid I have a button to save the search results to another table. When they click the button though I can't access the datatable because it is generated in the RadGrid1_NeedDataSource method.

If I can't write the contents of the datatable to my sql table then I am just going to write it when the search happens regardless of whether the user wants to save it or not and then when they click save I'll set a flag on the table. Hope this makes some sense, any suggestions appreciated...



4 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 16 Mar 2010, 04:58 PM
Hello DC,

A possible approach would be to disable the grid paging, temporarily, retrieve all the rows and then enable paging back again. This approach could be achieved by setting the RadGrid.AllowPaging property to false at a certain stage (for example RadGrid.PreRender event) of the life cycle and rebind the control invoking its Rebind() method, then traverse all items in it.

I hope this helps.

Sincerely yours,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
DC
Top achievements
Rank 1
answered on 16 Mar 2010, 05:49 PM
Thanks for the tip Radoslav. I will give that a try.
0
RRE
Top achievements
Rank 2
Iron
answered on 12 Apr 2010, 03:39 PM
Dear Radoslav,

I have the same problem.
I think this solution time consuming (I use the page property to avoid to load all the record and now I have to load all !)

Probably best solution is to attach directly to the ado/linq connection of the grid.

ciao

Renato
0
Radoslav
Telerik team
answered on 15 Apr 2010, 12:13 PM
Hi RRE,

There are two ways to get all the rows to which you are binding the grid and I am agree with you that to turn directly to the database and retrieve all rows count through data access operations is the best solution.

The other way is to set AllowPaging=false for the MasterTableView of the grid, rebind (Rebind()) the grid, retrieve the Items collection, set AllowPaging back to true and again rebind the grid, in this case if the RadGrid has a lot of rows the performance will be decreased.

Kind regards,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
DC
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
DC
Top achievements
Rank 1
RRE
Top achievements
Rank 2
Iron
Share this question
or