Grid setup - dataset -multiple tables

R

Robert Bravery

Hi all,
I have now correctly set up my dataset and two grids, so that the parent
navigates the child.
THe thing is that the child table is actually a lookup type table. It lists
billing types for the parent table, so that I just store a key in the parent
table, and the show the billing type description from the child
I need to set this up in one grid. I have played arround with the tables and
columns collection in the ID, but cant seem to get the child table
desciption clumn in the grid. I would really appreciate some guidence on how
to do this in the VS IDE.

Thanks
Robert
 
C

Cor Ligthert [MVP]

Robert,

The datatatableadapter plus all the design time parts around that in VS2005
is completely new.

Most of us where us used to do the things you ask completely in code (while
there was no datagridview as well). If the design part in VS2003 was correct
the design part was probably not changed. (Under the hood of the
datatableadapter is a lot working the same as in VS2003).

VS2005 is released now 2 months ago, don't expect to much expirience answers
using the designers. Before those with expirience leave the code part (if
they do that) will in my idea take some time.

On the otherhand the datagridview is not an easy control to handle in code.
So you are ahead now, with all the things that belong by being ahead, you
have to investigate a lot yourself.

Just some thoughts.

Cor
 
B

Bart Mermuys

Hi,

Robert Bravery said:
Hi all,
I have now correctly set up my dataset and two grids, so that the parent
navigates the child.
THe thing is that the child table is actually a lookup type table.

In a lookup scenario there is a master and lookup table. Keep in mind that
this is the opposite of parent-child. The lookup table is actually the
parent where the master table is the child.

May sound confusing, but consider the following: suppose you have a
BillingTypes Table and a Invoice Table, then the BillingTypes is the
lookup-table and therefore also parent, because one BillingType may have
many Invoice's with that BillingType.
It lists billing types for the parent table, so that I just store a key in
the parent
table, and the show the billing type description from the child
I need to set this up in one grid. I have played arround with the tables
and
columns collection in the ID, but cant seem to get the child table
desciption clumn in the grid.

Assuming that BillingTypes is a lookup table then you have two choices:

- Either show the Invoice table inside the grid and replace the fk column
inside the DataGrid with a DataGridComboBoxColumn. The
DataGridComboBoxColumn would also be connected with the BillingType table to
show a description and allow the user to select a different BillingType.
DataGridComboBoxColumn is unfortunately not included in NET1.1, you will
have to search the internet for sourcecode.

- Create the right relation, where BillingType is the parent. Then you can
add expression columns to your child table Invoices that uses fields from
the parent BillingTypes.

HTH,
Greetings
 
R

Robert Bravery

HI Bart,

I see where you going with this, but surley the, in my case, worktime should
be the parent, as it is the navigating table. I might have 5000 records in
worktime, but only 5 in billtype, which is the lookup. If I make lookup the
parent int the relation, then my primary navigation will only be 5 records.
No matter what I try with the table and column collection I can get this
right. All I want to do is show the billtype description in the grid inplace
of the FK billid
In dBASE this is so simple, whether I cant get my mind around .net or
whether I am doing something completely wron I don't know, BUT I need help

Thanks
Robert
 
B

Bart Mermuys

Hi Robert,

Robert Bravery said:
HI Bart,

I see where you going with this, but surley the, in my case, worktime
should
be the parent, as it is the navigating table. I might have 5000 records in
worktime, but only 5 in billtype, which is the lookup. If I make lookup
the
parent int the relation,
then my primary navigation will only be 5 records.

You only want to show one table so who says the parent must be the
navigating table, no in your case the child table is the navigating table
and the parent table (lookup) is not shown, it's only used to lookup values.
No matter what I try with the table and column collection I can get this
right. All I want to do is show the billtype description in the grid
inplace
of the FK billid

I already suggested two options, let my clarify the second option (which
doesn't use a ComboBoxColumn).

Suppose there is a worktime table which has a foreign key column to the
billtype table which is the lookup, the billtype table has a description
column or something like that.

Add the billtype and worktime table to a typed DataSet (anyway you do it),
then open the DataSet schema designer and make sure there is a relation
between them as follows:
Name: billtype_worktime
Parent: billtype - bill_id (pk)
Child: worktime - bill_id (fk)

Now, once you have this relation, go to the worktime table (still inside
DataSet schema designer), add a column to it by typing into it, name the
column something like "BillType" and choose a string as datatype. Then open
the properties window (make sure the new column remains selected) and then
set the property Expression to "Parent(billtype_worktime).description"
(without the quotes).

(billtype_worktime= name relation and description= a field from billtype)

Save and compile.

Put an instance of this DataSet on a Form, make sure there are two correct
DataAdapter configured. Then place a DataGrid on the Form and configure as
follows:
DataGrid
DataSource = yourDataSetOnTheForm
DataMember = "worktime"

That's it, now you should see the worktime table (child) with an extra
column "BillType" which shows you the description field out of the billtype
table (parent).
In dBASE this is so simple, whether I cant get my mind around .net or
whether I am doing something completely wron I don't know, BUT I need help

But you can't really compare both, VS2005 can be used for a wide range of
applications, while it does have DB support (UI and otherwise) it's in many
cases harder to setup an UI then it is with a database application like
access or dbase.

HTH,
Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top