Groups | Blog | Home
all groups > dotnet ado.net > april 2007 >

dotnet ado.net : binding source position when sorted


Rick
4/21/2007 7:43:11 AM
VS 2005

I want to make sure I have this concept down correctly.

I have a strongly typed datatable and a binding source connected to it.

On my windows form a grid is connected to the binding source.

When the grid is unsorted the datatable(bindingsource.positon).mycol =
DirectCast(bindingsource.current, datarowview).Item("mycol").

When I sort the grid the bindingsource.position is now out of synch with the
underlying datatable so the above are not equal.

I ask becuase I have to use a column value in a bindingsource positon
changed event and if the grid is sorted the value is no longer in synch.

Do I have this correct?

Rick

ClayB
4/21/2007 4:42:34 PM
Instead of datatable(bindingsource.positon), try using
datatable.DefaultView(bindingsource.positon). I think this should
match up with bindingsource.current even if the grid is sorted.

=========================
Clay Burch
Syncfusion, Inc.
Rick
4/21/2007 7:21:44 PM
Thanks, but that doesn't work.

With some sorts it is the same, but others no. I thought it was numeric vs
string sorts, but that didn't hold out.

I ended up by casting bindingsource.current as a datarowview and then get
the column value.

Rick

[quoted text, click to view]

Earl
4/21/2007 9:41:17 PM
Sort the BindingSource.

[quoted text, click to view]

AddThis Social Bookmark Button