[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 538
  • Last Modified:

How to select a single row from a dataset table

I have a dataset table bound to a couple of text boxes.    I have a find button a a list of residents come up.  When the user double clicks the row on the grid I caputre that rows ID #.  I then want to take the dataset table I have and and go the the record of the ID.  I am using a bindingsource object, and I know I can use bs.position to get current position but how do I find the record with the ID selected and then make that the currently selected row.

thanks in advance
0
mgmhicks
Asked:
mgmhicks
1 Solution
 
Jesus RodriguezIT ManagerCommented:
Why don't you bind the controls to the same bindingsource of the grid and will be easy for you.
Also, did you have a bindingnavigator or bindingsource for the textboxes or you fill the textboxes directly from your dataset on a sub??
0
 
mgmhicksAuthor Commented:
the textboxes are bound first.  I am using a bindingsource to do that so I can use bs.position + 1 and the textboxes fill with the next record.  However when the click the find button, they get a grid, bound to different source, but selects the ID.  ONce I have the ID I want to go the that record in the bs that matches the ID selected.
0
 
CodeCruiserCommented:
You can try 2 things

1) Use filter property and set a filter on ID. This would mean there is only one row and that will be shown
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.filter.aspx

2) Set Position property to index of row in grid and see if the two match
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.position.aspx
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now