Dropdowns not updating correctlyhttp://forums.asp.net/t/1195935.aspx/1?Dropdowns+not+updating+correctlyThu, 20 Dec 2007 22:44:17 -050011959352066979http://forums.asp.net/p/1195935/2066979.aspx/1?Dropdowns+not+updating+correctlyDropdowns not updating correctly <p>So I've got this Issue Tracking app that I'm doing in dynamic data.&nbsp; I've got a Projects table and an Issues table.&nbsp; When I edit Issues I get a drop down of projects so I can assign an issue to a project and that's all great.</p> <p>&nbsp;<br> My problem is that when I add a new project via the Projects page and then go to the Issues page the new project does not appear in either the filter or edit drop downs.&nbsp; How can I get these guys to update?&nbsp; I'm assuming there's some caching going on for performance but this is a real problem here.&nbsp; The only way I've found to fix the problem is to stop both the debugger and cassini and restart both.</p> <p>&nbsp;Thanks.<br> &nbsp;</p> 2007-12-18T21:31:46-05:002067033http://forums.asp.net/p/1195935/2067033.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>Without seeing your code, it may sound like caching as you said, or you may be storing the data for the projects in session.&nbsp; You may need to just recall the data to repopulate the list (which isn't a big hit). Or if you want to keep it in session your going to need some type of flag to say go and reload the project list because there is a new one in there.</p> <p>Feel free to publish your code and maybe we can help futher.</p> 2007-12-18T22:15:41-05:002067072http://forums.asp.net/p/1195935/2067072.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>&nbsp;Well, I'm using the Dynamic Data Extensions so there isn't really any code that's specific to the project.&nbsp; I'm not sure whether you picked up on that or not.</p> <p>&nbsp;If you did then how within the extensions do I repopulate the list?<br> &nbsp;</p> 2007-12-18T23:10:54-05:002067086http://forums.asp.net/p/1195935/2067086.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>Hi stevekain,</p> <p>There is an issue with how data context caching is done&nbsp;in the Preview version of Dynamic Data that might be the cause of the behavior that you are getting. However, I can't seem to be able to repro your scenario on my test box (i'm using the Products and Categories tables from Northwind though, but the parent-child pattern should be the same). Are you using the default Dynamic Data project without any customizations? Could you post your DB schema that illustrates the problem?</p> 2007-12-18T23:34:33-05:002068536http://forums.asp.net/p/1195935/2068536.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>I am using the default dynamic data project.&nbsp; I've added one or two renderhints but other than that it is standard.&nbsp; I do not have any table-specific pages or controls in action here.</p> <p>&nbsp;</p> <p>This is the script for the db that is having the problem:&nbsp;</p> <p>&nbsp;</p> <pre class="prettyprint">SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Projects]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Projects]( [ProjectID] [int] IDENTITY(1,1) NOT NULL, [ProjectName] [nvarchar](50) NOT NULL, CONSTRAINT [PK_Projects] PRIMARY KEY CLUSTERED ( [ProjectID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Statuses]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Statuses]( [StatusID] [int] IDENTITY(1,1) NOT NULL, [StatusName] [nvarchar](50) NOT NULL, [StatusLevel] [int] NOT NULL, CONSTRAINT [PK_Statuses] PRIMARY KEY CLUSTERED ( [StatusID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Priorities]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Priorities]( [PriorityID] [int] IDENTITY(1,1) NOT NULL, [PriorityName] [nvarchar](50) NOT NULL, [PriorityLevel] [int] NOT NULL, CONSTRAINT [PK_Priorities] PRIMARY KEY CLUSTERED ( [PriorityID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SecurityLevels]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[SecurityLevels]( [SecurityLevelID] [int] IDENTITY(1,1) NOT NULL, [SecurityLevelName] [nvarchar](50) NOT NULL, [LevelValue] [int] NOT NULL, CONSTRAINT [PK_SecurityLevels] PRIMARY KEY CLUSTERED ( [SecurityLevelID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Notes]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Notes]( [NoteID] [int] IDENTITY(1,1) NOT NULL, [IssueID] [int] NOT NULL, [CreatedByID] [int] NOT NULL, [NoteText] [nvarchar](4000) NOT NULL, CONSTRAINT [PK_Notes] PRIMARY KEY CLUSTERED ( [NoteID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Issues]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Issues]( [IssueID] [int] IDENTITY(1,1) NOT NULL, [ProjectID] [int] NOT NULL, [PriorityID] [int] NOT NULL, [StatusID] [int] NOT NULL, [CreatedByID] [int] NOT NULL, [AssignedToID] [int] NULL, [ResolvedByID] [int] NULL, [IssueTitle] [nvarchar](50) NOT NULL, [IssueDetails] [nvarchar](4000) NULL, CONSTRAINT [PK_Issues] PRIMARY KEY CLUSTERED ( [IssueID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Milestones]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Milestones]( [MilestoneID] [int] IDENTITY(1,1) NOT NULL, [ProjectID] [int] NOT NULL, [MilestoneName] [nvarchar](500) NOT NULL, [DueDate] [datetime] NOT NULL, CONSTRAINT [PK_Milestones] PRIMARY KEY CLUSTERED ( [MilestoneID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Users]( [UserID] [int] IDENTITY(1,1) NOT NULL, [UserName] [nvarchar](50) NOT NULL, [Password] [nvarchar](50) NOT NULL, [SecurityLevelID] [int] NOT NULL, CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ( [UserID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Notes_Issues]') AND parent_object_id = OBJECT_ID(N'[dbo].[Notes]')) ALTER TABLE [dbo].[Notes] WITH CHECK ADD CONSTRAINT [FK_Notes_Issues] FOREIGN KEY([IssueID]) REFERENCES [dbo].[Issues] ([IssueID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Notes_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[Notes]')) ALTER TABLE [dbo].[Notes] WITH CHECK ADD CONSTRAINT [FK_Notes_Users] FOREIGN KEY([CreatedByID]) REFERENCES [dbo].[Users] ([UserID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Issues_Priorities]') AND parent_object_id = OBJECT_ID(N'[dbo].[Issues]')) ALTER TABLE [dbo].[Issues] WITH CHECK ADD CONSTRAINT [FK_Issues_Priorities] FOREIGN KEY([PriorityID]) REFERENCES [dbo].[Priorities] ([PriorityID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Issues_Projects]') AND parent_object_id = OBJECT_ID(N'[dbo].[Issues]')) ALTER TABLE [dbo].[Issues] WITH CHECK ADD CONSTRAINT [FK_Issues_Projects] FOREIGN KEY([ProjectID]) REFERENCES [dbo].[Projects] ([ProjectID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Issues_Statuses]') AND parent_object_id = OBJECT_ID(N'[dbo].[Issues]')) ALTER TABLE [dbo].[Issues] WITH CHECK ADD CONSTRAINT [FK_Issues_Statuses] FOREIGN KEY([StatusID]) REFERENCES [dbo].[Statuses] ([StatusID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Table5_AssignedUsers]') AND parent_object_id = OBJECT_ID(N'[dbo].[Issues]')) ALTER TABLE [dbo].[Issues] WITH CHECK ADD CONSTRAINT [FK_Table5_AssignedUsers] FOREIGN KEY([AssignedToID]) REFERENCES [dbo].[Users] ([UserID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Table5_CreateUsers]') AND parent_object_id = OBJECT_ID(N'[dbo].[Issues]')) ALTER TABLE [dbo].[Issues] WITH CHECK ADD CONSTRAINT [FK_Table5_CreateUsers] FOREIGN KEY([CreatedByID]) REFERENCES [dbo].[Users] ([UserID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Table5_ResolvedUsers]') AND parent_object_id = OBJECT_ID(N'[dbo].[Issues]')) ALTER TABLE [dbo].[Issues] WITH CHECK ADD CONSTRAINT [FK_Table5_ResolvedUsers] FOREIGN KEY([ResolvedByID]) REFERENCES [dbo].[Users] ([UserID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Milestones_Projects]') AND parent_object_id = OBJECT_ID(N'[dbo].[Milestones]')) ALTER TABLE [dbo].[Milestones] WITH CHECK ADD CONSTRAINT [FK_Milestones_Projects] FOREIGN KEY([ProjectID]) REFERENCES [dbo].[Projects] ([ProjectID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Users_SecurityLevels]') AND parent_object_id = OBJECT_ID(N'[dbo].[Users]')) ALTER TABLE [dbo].[Users] WITH CHECK ADD CONSTRAINT [FK_Users_SecurityLevels] FOREIGN KEY([SecurityLevelID]) REFERENCES [dbo].[SecurityLevels] ([SecurityLevelID]) ON UPDATE CASCADE ON DELETE CASCADE</pre>&nbsp;&nbsp; 2007-12-19T15:44:52-05:002068991http://forums.asp.net/p/1195935/2068991.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>I am having a very similar issue.&nbsp; When an Update/Insert/Delete is performed on an associated table, the corresponding dropdown is not updated in the next view.&nbsp; I'm thinking that we're missing an update, load, or databind call somewhere.&nbsp; I am also using the default templates with only one view using minor customization.</p> <p>Thanks,</p> 2007-12-19T19:44:53-05:002069415http://forums.asp.net/p/1195935/2069415.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>The problem you both are seeing is indeed a bug in Dynamic Data caching. I'll try to see if we can provide some sort of workaround but I'm not sure it's possible from outside the assembly.</p> 2007-12-20T01:02:13-05:002070240http://forums.asp.net/p/1195935/2070240.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>same problem here too<br> </p> 2007-12-20T10:38:34-05:002070803http://forums.asp.net/p/1195935/2070803.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>&nbsp;Wow.&nbsp; That's a real disappointment.&nbsp; I sure hope there's a workaround because this bug is a true dealbreaker for me.&nbsp; And I should think for anyone considering actually using the preview . . .<br> </p> 2007-12-20T15:50:31-05:002070830http://forums.asp.net/p/1195935/2070830.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p></p> <blockquote><span class="icon-blockquote"></span> <h4>stevekain</h4> <p>&nbsp;Wow.&nbsp; That's a real disappointment.&nbsp; I sure hope there's a workaround because this bug is a true dealbreaker for me.&nbsp; And I should think for anyone considering actually using the preview . . .<br> </p> <p></p> </blockquote> <p></p> <p>I agree, this is dissapointing and it has brought our testing to a stand still.&nbsp; And if there's no work around, we are going to have to can it and take another approach.&nbsp; I guess if your application does not require immediate updating, this will be fine, but our application is for cleansing and reconfiguring data, and the records need to be updated across the board at the time they are changed, not when the application feels like re-caching the data.&nbsp; I would have thought this would be on the testing list BEFORE the preview.</p> 2007-12-20T16:07:05-05:002070839http://forums.asp.net/p/1195935/2070839.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>&nbsp;Honestly I can't imagine an application that wouldn't need immediate updating.&nbsp; I suppose if you had a database with no relations, but what real world app has that?</p> <p>&nbsp;I too have a hard time understanding how this got out the door as part of the preview.&nbsp; It took me 20 minutes of messing around with this thing to find the problem.<br> &nbsp;</p> 2007-12-20T16:11:05-05:002071104http://forums.asp.net/p/1195935/2071104.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>Sometimes the most obvious of things ellude us the most. Fortunately, I think we have been able to come up with&nbsp;a working solution to the problem. You will need to edit make changes to 2 files: FilterUserControl.ascx and ForeignKey_Edit.ascx. This solution uses C# (sorry, no VB for now) and should work the same for both inline and code-behind versions.</p> <ul> <li> <p>For <strong>ForeignKey_Edit.ascx</strong></p> </li></ul> <p>In the Page_Load method, replace the following line of code</p> <blockquote> <pre class="code">DropDownList1.DataSource = parentTable.Query;</pre> </blockquote> <p>with this</p> <blockquote> <pre class="code">DropDownList1.DataSource = parentTable.DataContextProperty.GetValue(<span style="color:#2b91af">Activator</span>.CreateInstance(<span style="color:#2b91af">DynamicDatabase</span>.TheDatabase.CreateDataContext().GetType()), <span style="color:blue">null</span>);</pre> </blockquote> <ul> <li> <p>For <strong>FilterUserControl.ascx</strong></p> </li></ul> <p>In the Page_Init method, replace the following line of code</p> <blockquote> <pre class="code">DropDownList1.DataSource = DataSource;</pre> </blockquote> <a href="http://11011.net/software/vspaste"></a> <p>with this</p> <blockquote> <pre class="code"><span style="color:blue">var </span>foreignKeyColumn = <span style="color:#2b91af">DynamicDatabase</span>.TheDatabase.GetMetaTable(<span style="color:blue">this</span>.TableName).FindColumn(<span style="color:blue">this</span>.DataField) <span style="color:blue">as </span><span style="color:#2b91af">DynamicMetaForeignKeyMember</span>; <span style="color:blue">if </span>(foreignKeyColumn != <span style="color:blue">null</span>) { <span style="color:green">// only kick in if we are dealing with a foreign key column </span>DropDownList1.DataSource = foreignKeyColumn.ParentMetaTable.DataContextProperty.GetValue(<span style="color:#2b91af">Activator</span>.CreateInstance(<span style="color:#2b91af">DynamicDatabase</span>.TheDatabase.CreateDataContext().GetType()), <span style="color:blue">null</span>); } <span style="color:blue">else </span>{ DropDownList1.DataSource = DataSource; }</pre> </blockquote> <p>The workaround is a bit ugly but it should work. Let us know if you experience more issues. Once we are able to verify that this fix works we will post updated versions of the relevant files.</p> 2007-12-20T18:30:51-05:002071132http://forums.asp.net/p/1195935/2071132.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>&nbsp;Excellent Marcin!&nbsp; That did it.&nbsp; Both the filter and edit dropdowns are now updating as expected.</p> <p>&nbsp;I'm really pretty impressed by the Dynamic Data stuff.&nbsp; It seems like for years different frameworks and controls promised this sort of out of the box functionality but none managed to actually provide it.</p> <p>&nbsp;From what I've seen of Dynamic Data so far it really delivers where previous attempts have failed.&nbsp; I think it really has the potential to get me 40% of my 80% (in the 80-20 rule) in about 10% of the time.&nbsp; Calculate that out and it's pretty great.&nbsp; Take my word for it.</p> <p>&nbsp;</p> <p>Thanks again.<br> <br> &nbsp;</p> 2007-12-20T18:42:47-05:002071170http://forums.asp.net/p/1195935/2071170.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>Yes, awesome, thank you for the fix.&nbsp; One note though, in the FIlterUserControl.ascx, there isn't a Page_Load function, you are using the Page_Init function instead.&nbsp; I really love the out of the box functionality of dynamic data.&nbsp; It makes the develoment time of data sites so much faster.&nbsp; Even with the customizations I've added, it still cut the development time by at least 75%.&nbsp; Thank you guys so much for this set of tools.</p> 2007-12-20T19:04:00-05:002071191http://forums.asp.net/p/1195935/2071191.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>Thanks Ron,</p> <p>I've updated the fix instructions.&nbsp;I am glad you are finiding Dynamic Data useful.</p> 2007-12-20T19:11:25-05:002071541http://forums.asp.net/p/1195935/2071541.aspx/1?Re+Dropdowns+not+updating+correctlyRe: Dropdowns not updating correctly <p>I have also placed a zip file with the modified files that you can simply unzip into your Dynamic Data project on <a class="" href="http://blogs.msdn.com/marcinon/archive/2007/12/20/dynamic-data-december-preview-context-caching-bug-fix.aspx"> my blog</a>.</p> 2007-12-20T22:44:17-05:00