Last post Dec 30, 2008 02:09 AM by albeealright
Dec 27, 2008 09:28 AM|albeealright|LINK
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)
Thanks in advance
Dec 27, 2008 03:45 PM|davidebb|LINK
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:
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
Dec 27, 2008 07:51 PM|sjnaughton|LINK
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?
Samples in VB
Dec 27, 2008 08:50 PM|davidebb|LINK
I've heard good things about
InstantVB, but it's expensive. They do offer a free trial.
Dec 28, 2008 04:44 AM|albeealright|LINK
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?
Dec 28, 2008 04:57 AM|albeealright|LINK
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:
I might use some c# in the same project in any case.
Dec 29, 2008 04:06 AM|davidebb|LINK
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).
Dec 29, 2008 04:30 AM|albeealright|LINK
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?
Dec 29, 2008 04:27 PM|sjnaughton|LINK
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.
Dec 29, 2008 07:25 PM|davidebb|LINK
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.
Dec 29, 2008 07:52 PM|sjnaughton|LINK
Didn't notice that until you mentioned it, well pointed out [:$]
Many to Many
Dec 30, 2008 02:09 AM|albeealright|LINK
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).
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.