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

[Solved] Loop Through the entire radgrid from an outside event

1 Answer 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 03 May 2013, 08:35 PM

 I have a radgrid on my page that I build programmatically within my Page_Init. I use the NeedDataSource to populate my grid. I have pagination enabled along with filtering.

When the user is on my screen the radgrid displays with information that spans multple pages. They can also use filtering to shrink the number of pages down. They will then have the ability to click on a regular asp button. This button will then try to gather all of the ids from all of the records in the radgrid. Not just the records on the current page.

An example:
    1. the radgrid has a pagination set to 100 records. the datasource has a total of 1600 records in it. So I have a radgrid of 16 pages, 100 at a time.
    2. the user uses a filter to shrink the number of pages down to 9 with a total of 850 records showing. the datasource still has 1600 because the radgrid is filtering and not the actual datasource.
    3. the user clicks the button. I want, on the server, to be able to traverse through all 850 records to get their specific datakeyitem and do something like this but the problem is the MasterTableView only has 100 records in it not the 850.

protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
            int detailID = dataItem.GetDataKeyValue("DetailID");
            //do something with the detailID
       }
   }

What else can I do to get this? I could try to store the ids that come back during the loading of the radgrid, but to do this I think I would need to take pagination off, rebind, get the ids, put pagination back on, rebind. I don't see something like this as an option because my datasource could have high number of records and binding twice would lead to user's waiting.

Thanks

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 May 2013, 03:55 PM
Hello,

You have to do this thing by below way.

but to do this I think I would need to take pagination off, rebind, get the ids, put pagination back on, rebind.

Note : another way is on button clicked, get the grid's filter expression and as per filter expression you have to apply this filter in your datasource and get the ID of your result.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or