Flatten two tables in DataGridView?

  • Thread starter Thread starter Burt
  • Start date Start date
B

Burt

I have a db with two tables, Parent and Child. A Parent will always
have 1 or 2 children: Child1, Child2, or both children. I'm writing a
C# windows app over these tables. The user, in a datagridview, will be
able to view, update, etc. the data.

Problem is, I have to flatten the two tables into one row in the dgv
per parent item. The three possible combinations, flattened, are shown
below:

Parent_ID1, Child_ID1, ChildID_2
Parent_ID2, ParentName2, Child_ID_1, null
Parent_ID3, ParentName3, null, ChildID_2

I have to display 20 or so fields for the parent and each of the 1-2
child rows. Any ideas how to handle this? I'm looking at creating a
temp table, flattening, then displaying on the grid. Others have
suggested flattening on the front end via DataTables. And how to
update the relational tables upon edit?

Thanks,

Burt
 
I have a db with two tables, Parent and Child. A Parent will always
have 1 or 2 children: Child1, Child2, or both children. I'm writing a
C# windows app over these tables. The user, in a datagridview, will be
able to view, update, etc. the data.

Problem is, I have to flatten the two tables into one row in the dgv
per parent item. The three possible combinations, flattened, are shown
below:

Parent_ID1, Child_ID1, ChildID_2
Parent_ID2, ParentName2, Child_ID_1, null
Parent_ID3, ParentName3, null, ChildID_2

I have to display 20 or so fields for the parent and each of the 1-2
child rows. Any ideas how to handle this? I'm looking at creating a
temp table, flattening, then displaying on the grid. Others have
suggested flattening on the front end via DataTables. And how to
update the relational tables upon edit?

Thanks,

Burt

Windwos eh.
So extGridView would be no use to you.

I think I'd bind to an object.
So your object can serve up an iList of a type you define with all
the fields in it.
Then you can flatten whetever out in the Get method and make whatever
construct you fancy in the update.

But really, sticking everything in one gridview isn't so good an idea
if you could avoid that.
 
Back
Top