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

Help!!! ArgumentOutOfRangeException.Parent and child relation.Filtering.

13 Answers 167 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jose Mejia
Top achievements
Rank 1
Jose Mejia asked on 23 Jul 2010, 10:24 AM
Hello!
Need your help!

I have following code:
if (_providerGridView.CurrentCell.ColumnIndex == 0) return;
Cursor.Current = Cursors.WaitCursor;
DataRowView row = (DataRowView) gNSSDataProviderBindingSource.Current;
DataRow provRow = row.Row;
var rows = provRow.GetChildRows(_relationName);
_pointGridView.DataSource = rows;
CheckSeletedRows(rows);
Cursor.Current = Cursors.Default;

which throws ArgumentOutOfRangeException  when I try to switch in parent grid when some filter is applied to child grid (for example I selected several rows in child grid  based on some condition).
I try to add _pointGridView.EndEdit() before
_pointGridView.DataSource = rows;

but nothing helps.

Stack trace is :
System.ArgumentOutOfRangeException was unhandled by user code
  Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
  Source="mscorlib"
  ParamName="index"
  StackTrace:
       at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
       at Telerik.WinControls.RadElementCollection.get_Item(Int32 index)
       at Telerik.WinControls.RadElement.DisposeChildren()
       at Telerik.WinControls.UI.GridTableBodyElement.CleanupRows()
       at Telerik.WinControls.UI.GridTableElement.Update_Reset(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
       at Telerik.WinControls.UI.GridTableElement.UpdateCore(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
       at Telerik.WinControls.UI.GridTableElement.Update(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
       at Telerik.WinControls.UI.GridViewTemplate.UpdateUI(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
       at Telerik.WinControls.UI.GridViewTemplate.Update(GridUINotifyAction action)
       at Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
       at Telerik.WinControls.Data.DataAccessComponent.Bind(Object dataSource, String dataMember)
       at Telerik.WinControls.Data.DataAccessComponent.set_DataSource(Object value)
       at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
       at DataProviderUI.ProivderTask.ProviderTaskControl.gNSSDataProviderBindingSource_CurrentChanged(Object sender, EventArgs e) in D:\SVN\Trunk\Archivarius\src\DataProviderUI\ProivderTask\ProviderTaskControl.cs:line 164
       at System.Windows.Forms.BindingSource.OnCurrentChanged(EventArgs e)
       at System.Windows.Forms.BindingSource.CurrencyManager_CurrentChanged(Object sender, EventArgs e)
       at System.Windows.Forms.CurrencyManager.OnCurrentChanged(EventArgs e)
  InnerException:

Thanks.

13 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 23 Jul 2010, 11:20 AM
Hello,

In the first if, .ColumnIndex == 0 return? Did you want to check if it's the first column or did you want to check if there is no column index like .ColumnIndex == -1?
0
Jose Mejia
Top achievements
Rank 1
answered on 23 Jul 2010, 11:30 AM
I want to be sure that it is not the first column. First column is for select purposes only.
0
Jose Mejia
Top achievements
Rank 1
answered on 26 Jul 2010, 09:58 AM
Anyone?
0
Jack
Telerik team
answered on 26 Jul 2010, 05:37 PM
Hi Jose Mejia,

This code looks OK and it cannot cause the described exception. However, this can happen when using a different thread when setting the data source. If this is the case, I can suggest using the Invoke method.

Please describe where do you call this code and/or send me your application in a new support ticket. I will investigate the issue further and will try to find a proper solution.

I am looking forward to your reply. 

All the best,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jose Mejia
Top achievements
Rank 1
answered on 27 Jul 2010, 01:01 PM
Hello! Thank you for reply.

There is no probelms with threads because this code is called in UI thread.
Mostly it works OK but as I said above when filtering applied to child grid and I want to switch my parent grid it produces exception.
Can there be problems with underlyaing dataset, because some columns I add in run-time?

Thanks in advance.
0
Emanuel Varga
Top achievements
Rank 1
answered on 27 Jul 2010, 01:36 PM
Hello again,

Sorry for the late replies but on what i'm hearing you should really take a look on the threading issues, because if you're adding some columns or data in real time then chances are that this is happening from an external action, event, timer and so on, which are usually on another thread, so chances are that this will fix your problem.

If not try the following:
First set the DataSource to null and then set it to another data source, it might work, or if not it would be great if you could provide a test project somehow, it will be easier to understand where your problem is coming from, right now i can just assume some things.

Hope it helps,

Best Regards,
Emanuel Varga
0
Jose Mejia
Top achievements
Rank 1
answered on 27 Jul 2010, 02:48 PM
Hello eveybody!

Nothing helps! Moreover sometimes it's throws NullReferenceException when I try to set data to datasource.
I have strong hunch that there is something wrong with filtering in child grid.
When I setup filter, then select all values based on filter, then set filter to nofilter, then switch parent grid everything is great.
If I try to switch parent grid while there is  filter on childgrid column then exceptions...
Is there any possiblity to turn off filtering when I switch parent grid, e.g.

if (_providerGridView.CurrentCell.ColumnIndex == 0) return;
           Cursor.Current = Cursors.WaitCursor;
           DataRowView row = (DataRowView) gNSSDataProviderBindingSource.Current;
           DataRow provRow = row.Row;
           var rows = provRow.GetChildRows(_relationName);
           //do some stuff to disable filtering
           _pointGridView.DataSource = rows;
           CheckSeletedRows(rows);
           Cursor.Current = Cursors.Default;

Any other assumptions?
Thank everybody for your attention.
0
Accepted
Jack
Telerik team
answered on 28 Jul 2010, 05:00 PM
Hi Emanuel, thank you for your suggestion and for your assistanse - much appreciated.

Jose, please open a new support ticket and send me your application - I will try to locate the issue. Without code it is hard to pinpoint the problem. You cannot suspend the filtering. You can disable it, but this will clear all expressions.

I am looking forward to your project.
 
Regards,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 28 Jul 2010, 05:06 PM
Hi Jack,

I would like to make a suggestion if possible, i would like to help as much as i can on these forums but sometimes it's really hard to do without seeing some actual code, wouldn't it be possible to allow zip attachments to the open forums?

I'm just talking about some very small applications in which people could ask for help on a concrete problem.

Best Regards,
Emanuel Varga
0
Jose Mejia
Top achievements
Rank 1
answered on 29 Jul 2010, 08:52 AM
Hello!

Thank you Emanuel, thank you Jack.
Unfortunatly I can't send you my project. I created a simple test project to reproduce error but as expected everything works great.
I can say that maybe two weeks ago it worked ok,but then I made several crucial changes to dataset and to grid and it was broken. Unfortunatly I cannot trace the cause of this error.

So for now I just simply add
DataRowView row = (DataRowView) gNSSDataProviderBindingSource.Current;
_pointGridView.MasterGridViewTemplate.FilterExpressions.Clear();
DataRow provRow = row.Row;

and every thing works great.
Thanks everybody for your time and attention.
0
Nikolay
Telerik team
answered on 02 Aug 2010, 05:47 PM
Hi guys,

Jose, please open a new support ticket and send us the project where the issue occurs. This will allow us to pinpoint the issue and will allows us to provide you with further assistance.

Emanuel, thank you for your suggestion. However, we currently do not have plans to allow our users to attach archive files to our forums. The reason for that is simple - the content that we may not want to appear in these files. Such content could be either viruses, or Dev assemblies that should not be distributed in the forums.

Kind regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 Aug 2010, 05:49 PM
Hello Nikolay,

I was just trying to help some people out faster and better

Best Regards,
Emanuel Varga
0
Nikolay
Telerik team
answered on 04 Aug 2010, 08:46 PM
Hi Emanuel,

We understand and appreciate your community efforts. Feel free to contact us should you have additional feedback or suggestions.

Regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jose Mejia
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Jose Mejia
Top achievements
Rank 1
Jack
Telerik team
Nikolay
Telerik team
Share this question
or