Find Row in a DataSet

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have a load event that fills a TableAdapter with data, for all branches of
a company.

this.branchTableAdapter.FillByCompanyNo(this.ProjectDataSet.Branch, Co_No);

This works fine. I would then like to position the TableAdapter at a given
branch given its address. How to do that?
 
Dave said:
I have a load event that fills a TableAdapter with data, for all branches of
a company.

No, that is not correct. The TableAdapter doesn't contain any data.
this.branchTableAdapter.FillByCompanyNo(this.ProjectDataSet.Branch, Co_No);

This works fine. I would then like to position the TableAdapter at a given
branch given its address. How to do that?

Use the filter property of the default view to select records:

this.ProjectDataSet.Branch.DefaultView.RowFilter = "Address = 'Berlin'";

Now the default view contains the records that matches the filter. The
data table still contains all the records.
 
Göran Andersson said:
No, that is not correct. The TableAdapter doesn't contain any data.


Use the filter property of the default view to select records:

this.ProjectDataSet.Branch.DefaultView.RowFilter = "Address = 'Berlin'";

Now the default view contains the records that matches the filter. The
data table still contains all the records.

Your line doesn't work. The form still stops at the first record.
 
On my form I have a ProjectDataSet, branchBindingSource, branchTableAdapter,
tableAdaptermanager, and a branchBindingNavigator.

I can sequence through the data using the branchBindingSource.
 
The following two lines of code was what I needed to find the row,

int itemFound= this.branchBindingSource.Find("Address" , AddressOwnedForm );
this.branchBindingSource.Position = itemFound;

This solved my problem.

 
Back
Top