|
-
Feb 22nd, 2003, 12:01 PM
#1
Thread Starter
Lively Member
DataRelation & Binding Not Working!!
I have created a one to one relation between parent “member” table and a child “Measurements” table, the relation works fine.
The problem is, the child table displayed in a DataGrid in the upper area of the form, & the bottom area I have some textbox which the data in the DataGrid binded to it, meaning when the user clicks on any row in the DataGrid, details should appear in this textboxs, but this is not happening !!!
I wonder if I have a coding error, next is the code used:
myDA.Fill(myDS, "Member")
myMeasureDA.Fill(myDS, "Measure")
‘ Add DataRelation the DataSet
myDS.Relations.Add("MemMsr", myDS.Tables("Member").Columns("MemberID"), myDS.Tables("Measure").Columns("MemberID"))
' cbSelect Member DataSource
Me.cbSelect.DataSource = myDS.Tables("Member")
Me.cbSelect.DisplayMember = "MemberID"
‘ Bind data in the first window form
Me.txtMemberName_e.DataBindings.Add("Text", myDS.Tables("Member"), "Name_e")
Me.dgMeasurements.DataSource = myDS.Tables("Measure")
‘ the next line is spoiling my next databinding
Me.dgMeasurements.SetDataBinding(myDS, "Member.MemMsr")
‘ bind the 2nd window form (*** this binding get spoiled ***)
Me.txtWeight.DataBindings.Add("Text", myDS.Tables("Measure"), "Weight")
Me.txtHeight.DataBindings.Add("Text", myDS.Tables("Measure"), "Height")
Any idea where is the problem?
Thanks for the help
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
-
Feb 22nd, 2003, 03:56 PM
#2
Frenzied Member
I couldnt exactly understand what you need, please describe more clearly.
Anyway considering that you have:
1- A master table called :Members
2- A details table called : Measurments
3- A datarelation object called: MemMsr
4- A dataset called myDS
5- A datagrid called:dgMeasurements
6- Two textboxes called: txtHeight, txtWeight
Then in order to have the data in the 'Members' table in datagrid and the details of each row in two textboxes then you may:
1-Bind your datagrid to the master table
2-Set AllowNavigation property of datagrid to False
3- Bind Textboxes as follows:
Me.txtWeight.DataBindings.Add("Text", Me.myDS, "Members.MemMsr.Weight")
or
Me.txtWeight.DataBindings.Add("Text", Me.myDS, "Members.MemMsr.Height")
-
Feb 23rd, 2003, 04:19 AM
#3
Thread Starter
Lively Member
Lunatic3 thank you for your reply.
Your understanding is correct till # 6 but....after that, Members data are displayed in a tab form (click to see the image)
http://www.adsc.net/cms/club0.jpg
And Measurements data are displayed in the Grid, if I clicked any Grid row the Measurements FULL info will be displayed in the save form under the grid in a texbox (http://www.adsc.net/cms/club1.jpg)
When I bind the Measurements data to the textbox as follow:
Me.txtWeight.DataBindings.Add("Text", myDS.Tables("Measure.MemMsr"), "Weight")
I get a run-time error says "value can't be null", while I don't see any thing null
Any idea please.
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
-
Feb 23rd, 2003, 11:25 AM
#4
Frenzied Member
From what I gathered you want to select an ID in Personl Tab, then going to the Measurments Tab you have several measurments of each ID and the selecting each of them will show you full details in textboxes in panel below. If that's what you want then do this:
VB Code:
Me.dgMeasurements.SetDataBinding(myDS, "Member.MemMsr")
Me.txtWeight.DataBindings.Add("Text", myDS,"Members.MemMsr.Wight")
you have to keep the syntax the same to keep synchronization. By the way MemMsr is a member of Members table (master table) not the child table.
-
Feb 24th, 2003, 11:37 AM
#5
Thread Starter
Lively Member
Excellent Lunatic3,
The mistake I was making is, I was binding to Measure DataSet not to the Relation !!
Thank you very much Lunatic3, you made my day
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
-
Feb 24th, 2003, 12:04 PM
#6
Frenzied Member
you're most welcome!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|