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

RadGrid Databinding

7 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
J
Top achievements
Rank 1
J asked on 06 Dec 2010, 05:29 PM
Hi,

I have bounded a Grid to a SQL2008 datasource. When querying the db to select approx 3000 records and populate the Grid, I get a time-out as it takes in excess of 5min.

Running the same query and populating a ASP.NET GridView took 30 seconds.  Question: is there a setting that should be set on the Telerik Grid to speed-up databinding?

 Thanks

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Dec 2010, 07:30 AM
Hi,


Have you considered taking advantage of the custom paging feature of Telerik radgrid? Thus only a subset of records will be visible on the rendered page that enables load the grid faster.

Checkout the following documentation that describes how to optimize the control performance on the client.
Client/server grid performance optimizations

Also checkout the following link to know more about improving the performance of RadControls.
Optimizing output, page load time and the overall performance of RadControls for ASP.NET AJAX


-Shinu.
0
J
Top achievements
Rank 1
answered on 07 Dec 2010, 10:01 AM
Thanks Shinu.

I did as you suggested with the custom paging, however there was no improvement; it still took forever to load and display the datasource in the RadGrid.  The grid did not fetch the specified data qty (10 rows in my example), there are over 3000 records retrieved. 

Also, the paging controls disappeared when Custom paging is enabled!

Any other suggestions?

Thanks
0
Tsvetina
Telerik team
answered on 10 Dec 2010, 11:01 AM
Hello,

Can you please paste the code that you use for custom paging (I assume you perform that logic in NeedDataSource), since there most probably is some problem with its implementation. If custom paging is configured correctly, the grid will not bind to the whole set of data and there should not be a problem with the pager.

Best wishes,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
J
Top achievements
Rank 1
answered on 13 Dec 2010, 02:35 PM
Thanks for your reply Tsvetina.

I have posted relevant code below.

Display results Display.aspx code behind:
protected void RadGridEmailResults_NeedDataSource( object source, GridNeedDataSourceEventArgs e )
{
    RadGridResults.DataSource = poRadGridResults;
}

When user clicks the 'Search' button , fetch the results form database via EntityFramework
protected void ButtonSearch_Click( object sender, EventArgs e )
{
 
    Dictionary<string, object> oParameters = new Dictionary<string,object>();
    oParameters.Add( "Source", RadComboBoxSource.Text.ToString( ) );

    using ( User oUser = new User( ) )
    {
        switch ( int.Parse( RadComboBoxType.SelectedValue.ToString( ) ) )
        {
            case 0:
                poRadGridResults = oUser.GetResults( oParameters );
                RadGridResults.DataSource = poRadGridResults;
                break;
            default:
                RadDatePicker1.SelectedDate = null;
                break;
        }
 
        RadGridResults.Rebind( );
 
    }
}


User Class:: GetResults() method defined below:

public
List<Result> GetResults( Dictionary<string, object> oParameters )
{
    List<Result> oResults;
 
    using ( Repository oRepository = new Repository( ) )
    {
        oResults = oRepository.GetResults( oParameters );
    }
 
    return oResults;


Data Access layer use Linq to Sql to fetch results

public
List<Result> GetResults( Dictionary<string, object> oParameters )
{
    string sSource = ( string )oParameters[ "Source" ];
    return new List<Result>( ( from m in poContext.Result
                             where
                             (
                                 m.source == sSource &&
                                 m.Ready == true &&
                                 m.Sent == false &&
                                 m.Failed == false
                             )
                             select m ).Distinct( ).AsQueryable<Result>( ) );
}



0
Tsvetina
Telerik team
answered on 16 Dec 2010, 10:55 AM
Hello,

Have you tried debugging the NeedDataSource to confirm that the Dictionary object which you are assigning to your RadGrid has less than 3000 records. It seems to me that the set of data is not filtered to a smaller number of records. When implementing custom pagins, you need to pass only the elements for the first page of the grid and to also set AllowCustomPaging="true" for your RadGrid. Please, take a closer look at the NeedDataSource event-handler in the online demo that Shinu linked to:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/custompaging/defaultcs.aspx

All the best,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
J
Top achievements
Rank 1
answered on 17 Dec 2010, 06:29 PM
Hello Tsvetina ,

I have been through the demo referenced here: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/custompaging/defaultcs.aspx

The problem seems to be one of implementation for my application.

Do you have another example demo that show's a full implementation.

Thx

0
Tsvetina
Telerik team
answered on 22 Dec 2010, 10:38 AM
Hello J,

The example in the demo section is the full code implementation. If the code from it is extracted in a new web form following these instructions you will see that it is runnable and works.

Generally, here is the set of steps that you need to take in order to implement custom paging:
  1. Set the grid or table view's AllowPaging and AllowCustomPaging properties to True.
  2. Set the table view's VirtualItemCount property to the total number of records that the grid can draw on. This allows the pager item to correctly represent the size of the pages you implement relative to the total number of records possible.
  3. Bind your grid using the NeedDataSource event. In the NeedDataSource event handler, implement code logic to extract the desired fixed number of records, based on the PageSize andCurrentPageIndex properties of the grid or table view.

So, in case you have done the first two steps, the only thing you should take care of is to pass only the desired records from your data source to RadGrid in NeedDataSource.

Regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
J
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
J
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or