Survey - implementing CRUD with "foreign name" instead of foreign key.

H

H5N1

hi all

it's extremely common scenario, so I would like to ask you how do you
usually implement CRUD functionality for following structure. Basically
it's all about displaying "foreign name" (ie. some textual description)
instead of foreign key.


GUI:

Table1ID
Info1
Table2.Name [Join on table2ID, DropDownList in Edit mode]


Database:

table1 table2
----------------- ------------------
PK table1ID PK table2ID
info1 Name
FK table2ID

this structure can describe for example some entity and it's category.


I'm using .net 2.0 typed datasets with TableAdapter Wizard, and I think
that, considering how ubiqitous is this structure, optimal solution
should be simpler than mine:

My way to do it:

It uses 2 objectDataSources and 2 corresponding TableAdapters:

---- one for displaying table1 with table2.name instead of table2ID

dataset uses JOIN on table2.id.

the drawback is that TableAdapterWizard cannot automatically generate
update/insert/delete statements. since it's multitable query


--- second ODS and tableAdapter to feed DropDownList in DetailsView's
edit mode
(simple select table2ID,name from table2)

dropdownlist works thanks to it's useful Text/Value parameters:
DataSourceID="odsTable2"
DataTextField="Name"
DataValueField="CourseCategoryID"
SelectedValue='<%# Bind("Table2ID", "{0}")




So, there must be 2 dataSources, and 2 tableAdapters, including one
with multiTable query which is a drawback in TAW.


One simpler solution comes to my mind - using the same DDList in
ItemTemplate as in EditItemTemplate, but then it has do be disabled
(and hence greyed out) to disallow it's changing - isn't there any way
to use a Label (or other read-only) control in such way (text/value)?


thanks for thoughts
 

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

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top