c# - How to display information from joined tables in a DataGridView -
i write software shows database contents in forms application. make easier explain, i'll use shopping list example.
- i have number of lists in 1 table
tlists
- i have number of
tproductpackages
in table - a list can consist of many productpackages , 1 productpackage can in many lists. m:n relationship reflected in separate table named
tlistprodpacks
. - a productpackage contains product. product can have several productpackages. in every
tproductpackage
table entry, there's foreign key fk_productid references entry in tabletproducts
.
my forms application should navigate through lists using bindingnavigator
. in bound controls, should display details of selected list. working fine. (just bound controls.)
all list contents (entries in tlistprodpacks
selected tlists
element) should shown in datagridview. working fine. details of productpackages (tproductpackages
items i.e. 1 hop more next table) displayed correctly. in table product value available id (fk_productid
) (foreign key tproducts).
is there way show product name (contained in tproducts
) in datagridview datasource tlistprodpacks
? (it's easy display tproductpackages
members, primary key tproductpackages
referenced tlistprodpacks
, using id can show other details tproductpackages
keep using same valuemember use different displaymember values single datagridview columns [using dropdown controls in dgv].) when jumping 1 table further (i.e. when jumping tproducts
table), not work anymore.
i know create custom query (join, view) want, cannot update database dataset anymore.
does konw how accomplish that? (i guess there's easy way provided framework , don't see it, right?)
i'm not sure if able describe accomplish enough. if not, please me provide in addition.
best regards, tom
u can relate tables using joins if contain primary key foreign key relation . using joins u can retrieve single result set containing fields u might need.
Comments
Post a Comment