[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Retrieving 'Child' Rows

Posted on 2004-11-29
4
Medium Priority
?
172 Views
Last Modified: 2010-04-17
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.

0
Comment
Question by:Craig_Muckleston
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:pratap_r
ID: 12696504
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
0
 

Author Comment

by:Craig_Muckleston
ID: 12706601
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)
0
 
LVL 11

Accepted Solution

by:
pratap_r earned 500 total points
ID: 12713150
no something like this

dsEmpList.Tables(0).DefaultView.RowFilter = "EmployeeNumber="  + Me.tboEmpNo.Text

that if your employeenumber is an integer or a number..

dsEmpList.Tables(0).DefaultView.RowFilter = "EmployeeNumber='"  + Me.tboEmpNo.Text.Replace("'","''") + "'"

the above if the emp# is a text (has alphabets in it)

you dont have to bind it to the datagrid again. once its bound its good.. you are talking about a vb.net windows application right? and not asp.net? there binding is slightly different

Have Fun!
Pratap
0
 

Author Comment

by:Craig_Muckleston
ID: 12715483
Hi Pratap,

Thanks for all your help, it works a treat.

Cheers
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Simple Linear Regression
Screencast - Getting to Know the Pipeline

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question