StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



DataGridView error when using a filter on a...Expand / Collapse
Author
Message
Posted 08/02/2007 7:39:58 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 6:27:30 PM
Posts: 1,268, Visits: 3,233
I have a DataGridView that I've bound to a BO via the BusinessBindgSource. I have a combo that allows the users to filter the contents displayed in the grid. It simply filters the BO, which filters the underlying datatable and viola, the grid is updated to display the new data. So far so good.

One of the columns displays some text based on the value of the underlying datatable and the state the form was opened in. I use the CellValueNeeded event to do the transformation. Still good.

This same column can be clicked to change the underlying value. When clicked, a sproc is fired that does some work, then the BO is refilled, re-filtered and the row reselected. Still good.

The problem occurs if I do click on a cell that does the above process, then select a new value in the combo that results in a set of records being displayed that is smaller then the current one AND the edited record's index is beyond those filtered records. I get a null exception, saying the index is out of range.

So these are the steps:
- Select a filter that has more items (more then the filter we select later)
- Edit one of the items (by clicking on the cell and running a sproc, updating the bo, reapplying the filter, reselecting the item)
- Select a filter that has less items (less than the current one)

I hope I've explained myself adequately.

So, any ideas why the datagridview is trying to index a row that isn't included in the new filter?

Post #10699
Posted 08/03/2007 8:54:10 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 09/26/2008 8:30:36 AM
Posts: 2,685, Visits: 1,886
My guess would be that the event you're handling isn't expected by the .NET developers to repopulate the grid.  They probably have a test within the OnCellValueNeeded() to make sure that the cell belongs to the underlying data source.  However, once it's checked the first time, their method is probably expecting the data source's row to exist for the rest of the method (It's probably not very common to replace the data source during the CellValueNeeded event).  So, when the call stack works it's way back down to the .NET methods, they're not expecting the data source to have changed (it's probably not a condition they ever expected...).  Sorry, Greg, I don't know what to tell you...


www.bungie.net
Post #10702
Posted 08/03/2007 9:58:21 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 6:27:30 PM
Posts: 1,268, Visits: 3,233
Thanks Ben, I'll look into that.
Post #10704
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 8:29pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.047. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.