Search code examples
c#asp.netentity-frameworkdynamic-data

When creating a new record, how do I fill some fields with values from the filter?


I'm working on an ASP.NET page, which basically is a quick hack around a database. It's used for an internal project and the site is set up in a way to provide several people read/write access to the data. Once a week, we collect a bunch of data from it, add it to an XML file and send it as part of an application update to our customers. (Those customers don't have direct access.)

Since it's just an internal project, there's almost no budget available for it's development. So we chose to keep things simple. We stored the data in an SQL Server database, created an Entity Framework class around this for data access and we put a Dynamic Data Site web application around this. Basically, something that can be set up real fast and without writing much code. It works quite well, too. Especially the filtering of records through boolean fields and table references is real cool.

However, during data entry a few users make minor mistakes. They've set up the filters to just filter a subset of a table and then click "New" to add a record to this subset. Unfortunately, the new record isn't defaulting to the values in those filters so users have to set the right values again. Too bad they occasionally miss this, thus some records end up with the wrong values.

So, when a user creates a new record, how do I ensure that this new record will copy the filter values as default? (And still allow the user to pick other values!)


Solution

  • Answered Here: Dynamically set defaults for scaffolded tables according to dynamic filters

    Check Dynamic Data Futures "Populate Insert templates with values from filters": http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14475

    Also, this blog post by Stephen Naughton: http://csharpbits.notaclue.net/2009/01/getting-default-values-from-list-page.html