<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET Dynamic Data</title><link>http://forums.asp.net/1145.aspx</link><description>Discussions regarding the new scaffolding framework in ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Add details for two entities by using 1 insert page</title><link>http://forums.asp.net/thread/3269570.aspx</link><pubDate>Wed, 01 Jul 2009 18:16:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3269570</guid><dc:creator>scaify</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3269570.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3269570</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I have figured this one out but it&amp;#39;s probably not the most graceful solution.&lt;/p&gt;
&lt;p&gt;I have created a private variable for a company and a user object at the top of the page&lt;/p&gt;
&lt;p&gt;In my button click event I have the following&lt;/p&gt;
&lt;p&gt;DetailsView2.InsertItem(True)&lt;br /&gt;DetailsView1.InsertItem(True)&lt;/p&gt;
&lt;p&gt;Dim cont As New mycityisModel.mycityisEntities&lt;/p&gt;
&lt;p&gt;c.Users.Add(u)&lt;br /&gt;cont.AddToCompanys(c)&lt;br /&gt;cont.SaveChanges()&lt;/p&gt;
&lt;p&gt;in the detailsdatasource iteminserting event I have the following code&lt;/p&gt;
&lt;p&gt;c = CType(e.Entity, mycityisModel.Company)&lt;br /&gt;e.Context.Detach(c)&lt;br /&gt;e.Cancel = True&lt;/p&gt;
&lt;p&gt;It will work for now until I found a more graceful solution&lt;/p&gt;</description></item><item><title>Re: Add details for two entities by using 1 insert page</title><link>http://forums.asp.net/thread/3268713.aspx</link><pubDate>Wed, 01 Jul 2009 11:21:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3268713</guid><dc:creator>scaify</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3268713.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3268713</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Thanks David&lt;/p&gt;
&lt;p&gt;My only question is how do I tie the 2nd details view to the 1st. The user should be inserted with the companyid of the record inserted from the 1st detailsview.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;in the click event I have&amp;nbsp;&lt;/p&gt;
&lt;p&gt;DetailsView1.InsertItem(True)&lt;br /&gt;DetailsView2.InsertItem(True)&lt;/p&gt;
&lt;p&gt;But in the savingchanges event there is only the one entity each time it is called.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;thanks in advance for the help&lt;/p&gt;</description></item><item><title>Re: Add details for two entities by using 1 insert page</title><link>http://forums.asp.net/thread/3268365.aspx</link><pubDate>Wed, 01 Jul 2009 09:10:37 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3268365</guid><dc:creator>davidfowl</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3268365.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3268365</wfw:commentRss><description>&lt;p&gt;Do you just want to have both details views do the right thing when you click on some other insert button? If so, then you can call DetailsView.InsertItem to fire the inserts on both. &lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview.insertitem.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview.insertitem.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Add details for two entities by using 1 insert page</title><link>http://forums.asp.net/thread/3267612.aspx</link><pubDate>Tue, 30 Jun 2009 23:17:38 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3267612</guid><dc:creator>scaify</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3267612.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1145&amp;PostID=3267612</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi sorry for any stupid questions, this is only my second week playing the EF framework.&lt;/p&gt;
&lt;p&gt;I have in my database a Company table and a User table. What I would like to do is be able to enter the company info and then the user info on the same insert page.&lt;/p&gt;
&lt;p&gt;I have created a custom page by copying the insert page into a company folder in my custom page folder. I have added a second details view and entity data source to the page in the init function I have the following code&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;DynamicDataManager1.RegisterControl(DetailsView1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DynamicDataManager1.RegisterControl(DetailsView2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table = DetailsDataSource.GetTable&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DetailsDataSource2.ContextTypeName = DetailsDataSource.ContextTypeName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DetailsDataSource2.EntitySetName = &amp;quot;Users&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DetailsView1.RowsGenerator = New HideColumnFieldsManager(table, PageTemplate.Insert)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DetailsView2.RowsGenerator = New HideColumnFieldsManager(DetailsDataSource2.GetTable, PageTemplate.Insert)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;In the design view I have set the AutoGenerateInsertButton to false for both detailsview&lt;/p&gt;
&lt;p&gt;When I run the project it shows the two forms and&amp;nbsp;validation works as expected. So I added a button and inside of the button I have the following code&lt;/p&gt;
&lt;p&gt;Dim cont As New mycityisModel.mycityisEntities&lt;br /&gt;cont.SaveChanges()&lt;/p&gt;
&lt;p&gt;However in the saving changes function osm.GetObjectStateEntries(Data.EntityState.Added) or any other enum returns zero entries.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Obviously I am doing something wrong or misunderstanding something. I don&amp;#39;t want to create a page with the fields added manually then in the button click event create the two entities and populate them from the fields then calling savechanges&amp;nbsp;as this seems unnecessary and there is probably a way to do it with dynamicdata. Is what I am asking doable. I have till the end of the week to get comfortable with EF or otherwise I have to go back to creating all the classes and input forms myself :( EF is definitely the way forward :)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any pointers are gratefully received&lt;/p&gt;</description></item></channel></rss>