Getting all the GridDataItems

8 posts, 0 answers
  1. Kathy
    Kathy avatar
    35 posts
    Member since:
    Sep 2010

    Posted 28 Nov 2010 Link to this post

    I have a RadGrid with paging.  There are 45 pages with 10 items per page.  If I call RadGrid1.Items, I only get the 10 items on the first page.  I want to get all 450 items.  How would I go about doing this?  Thanks.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2010 Link to this post

    Hello Karty,

    In order to access all GridDataItems ,disable the paging property. After accessing the data ,set the paging with desired size.Try the following code.

    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
           RadGrid1.AllowPaging = false;
            foreach (GridDataItem item in RadGrid1.Items)
            {
                //access the item
            }
            RadGrid1.AllowPaging = true;
            RadGrid1.PageSize = 3;
            RadGrid1.Rebind();
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 22 Nov 2012 Link to this post

    Hi Princy,

    I am facing the same issues , your provided solution not works .. please provide any example .

    Thanks.
     
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Nov 2012 Link to this post

    Hi Rohan,

    Try the following code snippet to achieve your scenario.

    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        RadGrid1.AllowPaging = false;
        RadGrid1.Rebind();
        foreach (GridDataItem item in RadGrid1.Items)
        {
            //Your code
        }
        RadGrid1.AllowPaging = true;
        RadGrid1.PageSize = 3;
        RadGrid1.Rebind();
    }

    Hope this helps.

    Regards,
    Princy.
  6. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 23 Nov 2012 Link to this post

    Hi Princy.

    Thank you very much for you replay ....
    problem still not solved ..

    RadGrid1.AllowPaging = false;
        RadGrid1.Rebind();
        foreach (GridDataItem item in RadGrid1.Items)
        {
            //Your code
        }
        RadGrid1.AllowPaging = true;
        RadGrid1.PageSize = 3;
        RadGrid1.Rebind();


    after the rebind the function i am not able to get selected row of grid ,  state of GridClientSelectColumn column become false ...
    how to get all selected row of radgrid
  7. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 27 Nov 2012 Link to this post

    Hello Rohan,

    You could save the selected items in a collection variable and use it when necessary:
    http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-client-sorting-paging-grouping-filtering.html
    or
    http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-on-sorting.html

    I hope this will prove helpful.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 27 Nov 2012 Link to this post

    Hi Eyup,

    Thanks for replay ,
    I have done all this things to persistence the selected row . My Problem is different , when ever i select the selected row from page 1 to page number such 4 or 5 i can able to access only the last page of radgrid . To access all the page or radgrid i am using this code
    RadGrid1.AllowPaging = false;
        RadGrid1.Rebind();
        foreach (GridDataItem item in RadGrid1.Items)
        {
            //Your code
        }
        RadGrid1.AllowPaging = true;
        RadGrid1.PageSize = 3;
        RadGrid1.Rebind();

    but after the rebind i am not able to get selected row ...
    is there any other  way to get all the row of radgrid please provide any code snap or document ....

    Thank you once again for replay...
  9. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 27 Nov 2012 Link to this post

    Hi Rohan,

    I have created a sample RadGrid web site where I implemented preserving and accessing the selected items on filter command. Please check out the attached application and let me know about the result.

    Kind regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017