Link to home
Start Free TrialLog in
Avatar of Craig_Muckleston
Craig_MucklestonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Retrieving 'Child' Rows

I have a database with a table (tblEmployees) that stores employees details. It is linked to a table called tblDocumentArchive that stores information about employee documents (ie contract, appraisals etc). The information stored are things like document title, create date etc. They are linked as a 1-many relationship by EmployeeNumber.

I have a .NET form that has an OleDbConnector, Adapters as necessary, and a Dataset (dsEmpDocs) that has both the above tables within it. I have created a datagrid (grdEmp) on my form that is populated with employee names at run time. (I use Me.adptEmployees.Fill(dsEmpDocs) to populate the list) All my other fields are populated with the employee details and as I moved through the list of employees, so the data changes in each field - as expected.

However, I have another datagrid (grdEmpDocs) that lists (or should anyway) each document that is 'attached' to the current employee, but when I move through my employees in grdEmp, my list of documents doesn't get refreshed (all the other data does)

How can I get my second grid to refresh with the first? I have been going around in circles trying everything programmatically with examples, or everything graphically with a few lines of code, and I think I have just confused myself as to where I am now.

Avatar of pratap_r
pratap_r
Flag of United States of America image

when the user navigates you have to filter the rows for the second datatable and then bind it

        dsEmpDocs.Tables(0).DefaultView.RowFilter = "employeeid=" + selectedempid

That should solve your problem.

Have Fun!
Pratap
Avatar of Craig_Muckleston

ASKER

Hi Pratap,

Thanks for the info. I'm a little stuck though (I'm new to .NET). I understand everything you say up to "employeeid=" + selectdempid.

Is this the same as saying
 
dsEmpList.Tables(0).DefaultView.RowFilter = "EmployeeNumber" Is _ Me.tboEmpNo.Text

What do I bind the DataGrid to then? (Sorry for sounding naive)
ASKER CERTIFIED SOLUTION
Avatar of pratap_r
pratap_r
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Pratap,

Thanks for all your help, it works a treat.

Cheers