Dynamically set defaults for scaffolded tables according to dynamic filters

让人想犯罪 __ 提交于 2019-12-25 04:27:43

问题


I have an ASP.NET Dynamic Data application that includes two tables, Departments and KPI's. When I capture KPI's, on the 'List' view, I set the Department field of the dynamic filter to e.g. 'Plant 1', but when I add a new KPI, I still have to select 'Plant 1' in a dropdown.

Is there any way I can cause the dropdown in the 'Insert' view to correspond to the dropdown in the dynamic filter? I can just see users filtering on 'Plant 1', and assuming any KPI's they add will fall under 'Plant 1'.


回答1:


I think what you want is to "Capture current filter criteria from List view when Insert link is clicked and use that filter criteria as the default values on Insert Page (ex: for foreign key relationships, DropDown Lists)"

The Dynamic Data Futures project does something like this. Check out: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14475 for the code. Run the "DynamicDataFuturesSample" web project and look at the section "Populate Insert templates with values from filters"


FROM DynamicDataFutres:
Populate Insert templates with values from filters
By default, Dynamic Data does not prepopulate relationship (foreign key) fields in an Insert view with default values. The DefaultValueHelper class contains helper methods that set up the Dynamic Data templates in such a way that the relationship fields are populated using values from the URL...


Also, Stephen Naughton has a blog post that solves the same problem (grabs filter criteria from query string)

http://csharpbits.notaclue.net/2009/01/getting-default-values-from-list-page.html



来源:https://stackoverflow.com/questions/1795249/dynamically-set-defaults-for-scaffolded-tables-according-to-dynamic-filters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!