Articles in this Series
- Introduction - A DynamicData Attribute Based Permission Solution using User Roles.
- Part 1 - Permissions Attribute (Metadata) Classes.
- Part 2 - Sample Metadata for project.
- Part 3 - The Helper Extension Methods.
- Part 4 - Limit Tables shown on Default page and List, Edit & Details etc.
- Part 5 - Generate Columns/Rows (using IAutoFieldGenerator)
- Part 6 - Miscellaneous bits
- Part 7 - Updating the ListDetails Page
- DynamicData - Limit the Filter Fields
- DynamicData - Automatic Column Update
- DynamicData - Limit Data Displayed By User
Limiting Data by the Current User
This is a really simple scenario where the table has a column which is update with the current user name at record creation (see: Automatic Column Update how to automatically update tables) all that is required is to add a WhereParameter to the pages LinqDataSources. In the Page_Load add the line for each LinqDataSource on the page (this line of code is for the List.aspx page).
GridDataSource.WhereParameters.Add(new Parameter("CreatedBy", DbType.String, User.Identity.Name));Obviously you may whish to add a CheckBox or RadioButton to toggle this feature or even add a filter to filter several users at once (see Marcin Dobosz Blog post Dynamic Data samples: Extending the FilterRepeater for details on how to extend the FilterRepeater)