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

Limit the number of records exported.

3 Answers 203 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan T
Top achievements
Rank 1
Alan T asked on 05 Jan 2012, 07:48 PM
I'm dealing with quite large datasets here, and my application seems to throw an IO timeout exception if i set ignorepaging to true and there's too much data.

So what i've done is created a hiddenfield for my total record count and i want to limit the number of records exported to 500, in the hope this will avert said exception, see below:,

If hd_rowcount.Value > 499 Then   
   Me.rg_properties.PageSize = 500
   Me.rg_properties.ExportSettings.IgnorePaging = False
End If

However this doesn't work. I'm assuming because the pagesize has already been set to 20, thus only 20 records are being exported.

Is there a way i can achieve the above results or are there any other suggestions you'd recommend?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jan 2012, 06:05 AM
Hello Alan,

Check the following forum thread which discussed similar scenario.
Export to Excel limit

Thanks,
Princy.
0
Alan T
Top achievements
Rank 1
answered on 06 Jan 2012, 10:25 AM
Hi Shinu, yeah i had already read that thread,

isn't that what i've done. I'm guessing my implementation of is it is incorrect though.

You can try to achieve similar functionality by using page size = 60000
(for instance) and IgnorePaging = false. Indeed you should handle this
type of functionality on your own.

Which is what i've done, but because the grid is already bound do a datasource with a pagesize specified, i'm guessing i need to rebind the grid after changing the pagesize. which then does a postback and breaks the export.

    Private Sub rg_properties_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rg_properties.ItemCommand
        If e.CommandName = Telerik.Web.UI.RadGrid.ExportToExcelCommandName Then
            rg_properties.ExportSettings.FileName = getFilename()
 
            If hd_rowcount.Value > 499 Then
                Me.rg_properties.PageSize = 500
                Me.rg_properties.ExportSettings.IgnorePaging = False
            End If
 
            rg_properties.MasterTableView.ExportToExcel()
          End If
End Sub
0
Alan T
Top achievements
Rank 1
answered on 06 Jan 2012, 05:58 PM
Managed to get this working.

Dim grid As RadGrid = rg_properties
If hd_rowcount.Value > 499 Then
    grid.PageSize = 500
    grid.ExportSettings.IgnorePaging = False
End If
 
 
grid.Rebind()
 
 
grid.MasterTableView.ExportToExcel()

take a copy of my grid then rebind that.

500 records still takes a long time, so i want the loading panel displayed. Which i've done, however i'm unable to get it to close after exporting.

Has anyone had any luck ? i've read every thread i can find here.
Tags
Grid
Asked by
Alan T
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Alan T
Top achievements
Rank 1
Share this question
or