0

Ive run into what seems to be kind of an odd issue with some legacy code. The code in question is creating a DataSet with 2 DataTables, and then defining the relationships between the tables before the data is used in a grid view (custom user control) - with child records grouped under the appropriate parent record. The relations seem to be setup correctly, with the ParentColumn and ChildColumn both set to columns with the matching values. However, if two other separate column values are the same between two parent, then all of the child records are showing underneath only one parent.

Dataset info

Resource table

| UserId | MemberId | FirstName | LastName | Email |
| 53C ... | C3A ........ | James ..... | Barnes .....| jbarnes@rmail.com |
| AE4 ... | 07A ......... | James ..... | Barnes .....| buckybarnes@hotmail.com |

Request table

| RequestId | OwnerId | MemberId |
| 1234 ........| 53C .......| C3A ......... |
| 2345 ........| AE4 .......| 07A ..........|
| 7689 ........| AE4 .......| 07A ......... |

In this scenario the rows from the Resource table are the parent records, and the rows from the Request table are the children. Based on this my expectation is that there would be one row underneath the record for 53C James Barnes, and 2 rows underneath AE4 James Barnes. When in actuality I am seeing 3 rows underneath 53C (I think) James Barnes. And the other James Barnes isn't listed.

Here is the setup for the DataRelation:

DataRelation resource_timesheet = new DataRelation(
                "relationName",
                ResourceTable.Columns[0],
                RequestTable.Columns[1],
                false);

Since the parent/child value columns are being referenced directly I would think that the column name would not matter (Maybe?).

Ive gone through a ton of articles that I could find here and elsewhere, and I have not found anything similar. Other than those cases where First and Last name in resource table match, everything else is working fine.

Justin Greywolf
  • 650
  • 7
  • 17
  • My gut tells me it might be the custom user control. Have you tried just a regular `DataGrid` to see how it displays? You can write some debugging code that does `GetChildRows` to see if the relation is working. – Crowcoder Dec 06 '19 at 21:46
  • My gut kind of tells me the same thing. There is SO much code in here around that custom control that Im not even sure how easy it would be swap a standard control in to validate. Wait - I just found custom binding that is using a hashset to keep track of resources that is using firstname+lastname as the key. – Justin Greywolf Dec 06 '19 at 22:49

0 Answers0