Answered by:
Master Detail

Question
-
User-902880243 posted
Hi,
I've had a play around with Dynamic Data and am impressed with what can be achieved in virtually no time. I'm going to use it for a project I've just started for a client since they have small timescales for delivery and I don't have the time to maintain data entry screens especially since the database design is likely to alter in the next few weeks (..and they'd like to see their data\reports during this period - madness).
I would like to put together master detail pages whilst still harnessing the dynamic nature of this project type.
I have one table that has a number of detail tables associated with it and would like to be able to edit, insert etc.. all the detail tables (keeping the association with the master table entry during the process).
I'm currently working through this example but would appreciate some general guidance on best practice (any code examples vb.net preferred would also help)
http://csharpbits.notaclue.net/2008/09/dynamic-data-custom-pages-with-ajax.html
Thanks in advance
Saturday, December 27, 2008 9:28 AM
Answers
-
User1641955678 posted
It's sounds like you're dealing with a couple Many To Many relationships where the junction node also contains data. Do both ContractRoute and VariationRoute contain extra data? You may want to include the schema graph to make the schema really clear.
That would make it somewhat similar to the OrderDetails relationship in Northwind, which joins Products and Orders and adds extra data. It's often useful to look at analogy in well known schemas like Northwind or AdvWork as they are well known to most and were designed to contain an interesting set of relationship types.
Also, are you using Linq To Sql or Entity Framework? That can make a big difference in the way Many To Many relationships are handled (although mostly in the case where the junction has no data).
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 29, 2008 4:06 AM
All replies
-
User1641955678 posted
Just trying to understand in more details your scenario. Taking Northwind as an example, can you describe the page you're looking for in more details? e.g. do you want more:
-
A page that shows a details view of a Product, along with a details view of the products's Category
-
A page that shows a list view of a Product, along with a details view of the selected products's Category
-
A page that shows a details view of a Category, along with the list of products in that category
-
You get the idea...
Another important question is whether you're looking for a generic solution that would do this for all similar relationships, or whether you want to write a custom page. Some guidance here.
thanks,
DavidSaturday, December 27, 2008 3:45 PM -
-
User-330204900 posted
I'd love to help with the above sample in VB but I don't have the time at the mement. I wonder if there is a c# to VB converter that works well with c# 3.0?
Saturday, December 27, 2008 7:51 PM -
User1641955678 posted
I've heard good things about InstantVB, but it's expensive. They do offer a free trial.
David
Saturday, December 27, 2008 8:50 PM -
User-902880243 posted
davidebb
firstly thanks for the reply.
the datastructure for the page in question is based on Contracts:
a Contract has many ContractRoute's (in english a contract has many routes however a route can be on more that one contract hence the junction table)
a Contract has many ContractVariation's (the contract can vary)
a ConractVariation has many ContractVariationRoute's (the ContractVariation will have Route specific data which can vary hence ContractVariationRoute)
(as you can see there are two paths from contract to route however this is needed since there is specific data stored at ContractRoute level which is not involved with variations)
To alter ContractVariationRoute the user would need to select the Contract, the ContractVariation and the ContractRoute.
So at the top level I'd need a simple dropdown of Contracts with a grid or list of Variations for that Contract and a grid or list of the Routes for that Contract.
The user selects the Variation and the Route (in the context of the contract) and will then be presented with grid or list of the ContractVariationRoute's
I'm looking to put this in as a specific page for this scenario only not as a generic solution but obviously I'd like the changes in the tables going forward to be picked up in the same dynamic manner.
I hoping that made sense?
Sunday, December 28, 2008 4:44 AM -
User-902880243 posted
sjnaughton
no worries, I'm thankful enough with the example you've already put together
I've been using this free conversion site with some success:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
I might use some c# in the same project in any case.
Sunday, December 28, 2008 4:57 AM -
User1641955678 posted
It's sounds like you're dealing with a couple Many To Many relationships where the junction node also contains data. Do both ContractRoute and VariationRoute contain extra data? You may want to include the schema graph to make the schema really clear.
That would make it somewhat similar to the OrderDetails relationship in Northwind, which joins Products and Orders and adds extra data. It's often useful to look at analogy in well known schemas like Northwind or AdvWork as they are well known to most and were designed to contain an interesting set of relationship types.
Also, are you using Linq To Sql or Entity Framework? That can make a big difference in the way Many To Many relationships are handled (although mostly in the case where the junction has no data).
David
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 29, 2008 4:06 AM -
User-902880243 posted
I'm currently using Linq To Sql (although if I can get it to work in Entity Framework I'd give that a shot but I'm now running out of time).
I've managed to work out some of what I'm after by simply dropping the linqDatasource and setting that for Contracts dropdown, another linqDatasource for ContractRoutes grid underneath with the where filtered by the Contracts datasource, the same for ContractVariations. Now all I need is a third linqDatasource filtered by the two preceeding linqDatasource's to give me the grid for ContractVariationRoutes. This , it seems, can all be achieved in the designer.
Now I need to get the insert pages done for the three above tables.
Is it possible to use or call up the Insert pages for these tables dynamically so that I don't have to create then?
Monday, December 29, 2008 4:30 AM -
User-330204900 posted
It's worth noteing that Entity Framework makes working with Many to Many relativly easy as it turns the kink table into a relationship. Have a look at Davids sample on his blog here A ‘Many To Many’ field template for Dynamic Data which give a good explination.
Monday, December 29, 2008 4:27 PM -
User1641955678 posted
Steve, note that this only happens for the case where the junction table has no data, as in Employees / Territories in Northwind. When it has data, as in OrderDetails, the Junction table can't be removed, and I don't think EF is much different from L2S in those scenarios.
David
Monday, December 29, 2008 7:25 PM -
User-330204900 posted
Didn't notice that until you mentioned it, well pointed out [:$]
Monday, December 29, 2008 7:52 PM -
User-902880243 posted
thanks to all for responses.
Everything I needed to sort out this master detail page I found in these worked examples. (sjnaughton whatever's driving you to provide all this stuff I hope it keeps going- these examples have saved me valuable hours).
http://csharpbits.notaclue.net/2008/07/dynamic-data-and-custom-pages.html
it shows how to set up master detail preserving dynamic fields.
The only thing I did differently\additionally was include the insert hyperlink at the bottom of each detail grid so the user has the ability to insert.
Post insert I have noticed it navigates back to the standard list page as opposed to the page the insert page was called from, this I need to sort out but I'll put this in a new post.
Tuesday, December 30, 2008 2:09 AM