Get the BindingSource position based on DataTable row

Ronald picture Ronald · Aug 30, 2010 · Viewed 9.4k times · Source

I have a datatable that contains the rows of a database table. This table has a primary key formed by 2 columns.

The components are assigned this way: datatable -> bindingsource -> datagridview. What I want is to search a specific row (based on the primary key) to select it on the grid. I cant use the bindingsource.Find method because you only can use one column.

I have access to the datatable, so I do manually search on the datatable, but how can I get bindingsource row position based on the datatable row? Or there is another way to solve this?

Im using Visual Studio 2005, VB.NET.

Answer

Arman picture Arman · May 18, 2013

I am attempting to add an answer for this 2-year old question. One way to solve this is by appending this code after the UpdateAll method(of SaveItem_Click):

Me.YourDataSet.Tables("YourTable").Rows(YourBindingSource.Position).Item("YourColumn") = "YourNewValue"

Then call another UpdateAll method.