Index was out of range

Hello,

I have this problem with my code, when I filled my sfdatapager worked fine, but when I'm clicking another page in my sfDataPager this error shows.
How can I resolve my problem? 

Thanks a lot

5 Replies

JG Jai Ganesh S Syncfusion Team May 25, 2018 04:02 AM UTC

Hi Tomas, 
 
We have analyzed your query and we couldn’t see any stack trace in your update. Could you please share the below details, so that we can proceed further on this issue? 
 
  1. Essential studio version
  2. Please share the details for any customization you did in your application
  3. Complete stack trace for the issue
  4. Could you please let us know the details on in which control you have used with SfDataPager?
  5. Kindly share the sample or XAML codes along with the ViewModel how you have used in your application
 
Regards, 
Jai Ganesh S 



TR Tomas Raziel Garza Amaya May 28, 2018 05:26 PM UTC

Hi,

I am using Essential Studio 16.
I only customized the visual style of the RibbonWindow with the next line:

    xmlns:skin="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
    skin:SfSkinManager.VisualStyle="Office2016White"
    Office2010Icon="/Program;component/Resources/Images/Logo.png"

My xaml with the dataGrid and DataPager is:

<syncfusion:SfDataGrid EnableDataVirtualization="True" Grid.Row="1" Name="MainGrid" AllowFiltering="True" AllowResizingColumns="True" AllowResizingHiddenColumns="True" AllowTriStateSorting="True" Height="auto" Background="White" ShowGroupDropArea="False" Grid.RowSpan="2" BorderBrush="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=sfDataPager, Path=PagedSource}" RowHoverHighlightingBrush="#FFEEEEEE" RowSelectionBrush="#FFDADADA" CurrentCellBorderBrush="#FFB2B2B2" SelectionForegroundBrush="Black" SelectionMode="Extended" SelectionUnit="Row"
                                   DetailsViewExpanding="MainGrid_DetailsViewExpanding"
                                   GridCopyContent="MainGrid_GridCopyContent" 
                                   GridPasteContent="MainGrid_GridPasteContent" 
                                   PreviewKeyDown="MainGrid_PreviewKeyDown" 
                                   PreviewMouseDoubleClick="MainGrid_PreviewMouseDoubleClick" >
                <syncfusion:SfDataGrid.LayoutTransform>
                    <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" ScaleY="{Binding Path=Value, ElementName=zoomSlider}" />
                </syncfusion:SfDataGrid.LayoutTransform>
                <syncfusion:SfDataGrid.DetailsViewDefinition>
                    <syncfusion:GridViewDefinition RelationalColumn="Details" >
                        <syncfusion:GridViewDefinition.DataGrid>
                            <syncfusion:SfDataGrid x:Name="GridDetalles" AutoGenerateColumns="False" AllowSorting="False" AllowResizingColumns="True" AllowResizingHiddenColumns="True" />
                        </syncfusion:GridViewDefinition.DataGrid>
                    </syncfusion:GridViewDefinition>
                </syncfusion:SfDataGrid.DetailsViewDefinition>
            </syncfusion:SfDataGrid>

            <syncfusion:SfDataPager Grid.Row="1" Name="sfDataPager" VerticalAlignment="Bottom" AccentBackground="Gray" AccentForeground="White" HorizontalAlignment="Center" NumericButtonCount="10" Visibility="Visible" PageSize="50" Margin="0 0 0 15" 
                                    PageIndexChanged="sfDataPager_PageIndexChanged" Foreground="Black"/>

In my code I just use:

        private void sfDataPager_PageIndexChanged(object sender, Syncfusion.UI.Xaml.Controls.DataPager.PageIndexChangedEventArgs args)
        {
            lblStatus.Text = "";
        }

It is all that I use in my program. I repeat the problem:

When I clicking on the next page or any number of page, Visual Studio change to break mode, and the error "Index was out of range" appear.


SJ Sathiyathanam Jeyakumar Syncfusion Team May 30, 2018 03:51 AM UTC

Hi Tomas, 
 
We have analyzed your code snippets and tried to reproduce the reported problem with the simple sample. We have found that the issue was reproduced due to you have set the EnableDataVirtualization as true for DataGrid control. Paging will be act like a virtualization to load the current page records alone for each page and here there is no need to set EnableDataVirtualization.  
 
You can avoid to set EnableDataVirtulaization as true from your xaml code, for resolving the reported issue. Please find the modified sample from the below link.

Sample link:
MasterDetailsViewDemo-919639921.zip 
 
 
If you really need this flag to be set to the DataGrid control and then please let us know the purpose for that to use in paging. 
 
 
Please let us know if you have any future assistance on this.  
 
Regards, 
Sathiyathanam 



TR Tomas Raziel Garza Amaya May 31, 2018 03:49 PM UTC

Thank you so much, I changed the value and its running.


SJ Sathiyathanam Jeyakumar Syncfusion Team June 1, 2018 12:33 PM UTC

Hi Tomas, 
 
Thank you for your update. 
 
We are happy to hear that the reported problem has been fixed with the given details. 
 
Additional information: EnableDatavirtualization is used to improve the performance while scroll the huge amount of data. You can load the data for current page alone using OnDemandPaging instead of loading data for all pages this is used to improve the performance when handle the huge amount of data. 
 
You can get more details about OnDemandLoading from the below links. 
 
Regards, 
Sathiyathanam 


Loader.
Up arrow icon