Datagrid Bug - Known Workaround?

  • Thread starter Thread starter Ken Cooper
  • Start date Start date
K

Ken Cooper

Hi All,

I'm getting the following error which I can't fix by the workarounds I've
seen suggested:
"Error when committing the row to the original datastore. Index was outside
the bounds of the Array"

This occurs under the following circumstances:

I have a dataset which gets returned from a WebService
I create a dataview based on a table in this dataset which is used as the
datasource for a datagrid in a Windows Forms Application

The datagrid is set to readonly - I want to be in control of all updates and
deletions.

I delete a record which was displayed in the datagrid, and get a new dataset
from the database and rebind the view to the datagrid. I then click on any
row in the datagrid and get the above error.

How can I tell the datagrid to forget the original data? Discard it? That I
don't want it to commit anything to a datastore? I'm finished with it. Let's
move on, I have fresh data?

Any help appreciated.

Ken
 
It's not the dataset that's at fault here, it's the datagrid.

I have discarded the old dataset and have a completely new one from the
webservice that I bind to the datagrid. The new binding works, the new data
is displayed, but when I click on the datagrid I get the message "Error when
committing the row to the original datastore. Index was outside the bounds
of the Array".

(I have tried AcceptChanges on the dataset, immediately after receiving the
new data from the WebService, but this makes no difference)

mdsOrders = svc.OrderSearch([Search Criteria])

mdsOrders.AcceptChanges

DataGridOrderSearchResults.CurrentRowIndex = 0 'To ensure valid
CurrentRowIndex with new datasource

mdvOrderSearchResults = New DataView(mdsOrders.OrderSummary, "",
strSortOrder.ToString, DataViewRowState.Unchanged)

DataGridOrderSearchResults.DataSource = mdvOrderSearchResults

DataGridOrderSearchResults.Refresh()

The data is displayed correctly, I click on a row, I get the error

I can't trap error the error in a datagrid event and discard it, it seems to
be the datagrid remembering the old databinding and trying to reconcile
changes, event though I have set the datagrid to be readonly and have tried

MyDataGrid.DataBindings.Clear

before setting the new datasource.



goneWildCoder said:
Ken,

In reference to your question "How can I tell the datagrid to forget the
original data? Discard it?" -->
 
Back
Top