System.IndexOutOfRangeException: Index was outside the bounds of the array.

IndexOutOfRangeException is thrown when trying to select a Date range from the DateRangePicker control in v19.3.0.43+

It works in v19.2.0.62


9 Replies

DR Deepak Ramakrishnan Syncfusion Team October 18, 2021 01:56 PM UTC

Hi David, 
 
Greetings from Syncfusion support. 
 
We have validated the reported issue in our end , but unfortunately we couldn’t able to reproduce it in our end with the mentioned version . We have attached video demonstration and sample for your reference. 
 
 
 
If you still able to reproduce the issue in your end , We request you to provide the below details to proceed in our end 
 
1.Simple sample or modify the provided sample which reproduces the issue. 
2.Video demonstration which reproduces the issue 
3.If any specific replication procedure followed other than the issue followed in provided video. 
 
Thanks, 
Deepak R. 



CB Craig Boucher October 18, 2021 03:45 PM UTC

I'm also experiencing this error with the SfGrid component after I edit a row and and press enter.  Here is my SfGrid declaration:

SfGridHtml.jpg

Here is the source code:

SfGridSourceCode.jpg



RS Renjith Singh Rajendran Syncfusion Team October 19, 2021 08:34 AM UTC

Hi David, 

We have analyzed your codes, and we could see that you have not enabled IsPrimaryKey for any of the columns in Grid. We suspect that this might have caused the problem. 

So, we suggest you to ensure to define a unique valued column as a primary key column in grid. It is a must to define a unique valued column as IsPrimaryKey when perform edit action in grid. Please refer the below documentation for more details, 

Please get back to us if you need further assistance. 

Regards, 
Renjith R 



DA David October 20, 2021 04:16 AM UTC

Hi

I've updated the nuget package to 19.3.0.46 and it's now working.



RS Renjith Singh Rajendran Syncfusion Team October 20, 2021 08:56 AM UTC

Hi David, 

Thanks for your update. Please get back to us if you need further assistance. 

Regards, 
Renjith R 



CB Craig Boucher replied to Renjith Singh Rajendran October 20, 2021 02:14 PM UTC

Thanks Renjith, adding the primary key worked.

Craig



RS Renjith Singh Rajendran Syncfusion Team October 21, 2021 03:46 AM UTC

Hi Craig, 

Thanks for your update. We are glad to hear that the provided suggested helped in overcoming the problem. Please get back to us if you need further assistance. 

Regards, 
Renjith R 



MA macronbell September 6, 2022 04:49 AM UTC

This exception means that you're trying to access a collection item by index, using an invalid index. An index is invalid when it's lower than the collection's lower bound or greater than or equal to the number of elements it contains. Indexing an empty list will always throw an exception. Use a method like Add to append the item to the end of the list, or Insert to place the item in the middle of the list somewhere, etc. You cannot index into a c# list if that offset doesn't exist. IndexOutOfRangeException exception is thrown as a result of developer error. Instead of handling the exception, you should diagnose the cause of the error and correct your code.

Handling the Exception:

Use for-each loop: This automatically handles indices while accessing the elements of an array.

Use Try-Catch: Consider enclosing your code inside a try-catch statement and manipulate the exception accordingly. As mentioned, C# won’t let you access an invalid index and will definitely throw an IndexOutOfRangeException. However, we should be careful inside the block of the catch statement, because if we don’t handle the exception appropriately, we may conceal it and thus, create a bug in your application.





SP Sarveswaran Palani Syncfusion Team September 7, 2022 07:48 PM UTC

Hi Macronbell,

Thanks for the suggestion.

We appreciate you for taking time to informing us.

Regards,

Sarveswaran PK


Loader.
Up arrow icon