VB.NET – Get Bindingsource Location according to DataTable

I have a data table containing rows of a database table. The table has a primary key formed by 2 columns.

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

I can access the data table, so I manually search the data table, but how do I get the bindingsource row location based on the data table row? Or is there another solution?

I use Visual Studio 2005, VB.NET.

I Trying to add an answer to this 2 year old question. One way to solve this problem is to append this code after the UpdateAll method (SaveItem_Click):

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

Then call another UpdateAll method.

I have a data table with rows of a database table. The table has a primary key formed by 2 columns.

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

I can access the data table, so I manually search the data table, but how do I get the bindingsource row position based on the data table row? Or is there another solution?

I am using Visual Studio 2005, VB.NET.

I am trying to add an answer to this 2-year-old question. One way to solve this problem is to append this code after the UpdateAll method (SaveItem_Click):

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

Then call another UpdateAll method.

Leave a Comment

Your email address will not be published.