How to change order of dynamic filter controls?
.net, asp.net, asp.net-dynamic-data, c#, dynamic-data
Solution
OK so I ended up just manually reordering the controls list on the custom code-behind page like so:
Control date_filter = FilterRepeater.Controls[1];
FilterRepeater.Controls.RemoveAt(1);
FilterRepeater.Controls.Add(date_filter);
Of 3 controls on the page this takes the 2nd out and adds it onto the end.
If I need to use again I might create a method and search on control name.
This is a crude solution but it suits me for this one off scenario. If anyone finds a better way let me know.
OK better way:
- Install this: http://nuget.org/packages/NotAClue.DynamicData.Extensions
- Add reference "using NotAClue.ComponentModel.DataAnnotations;" if you are using a separate entity page
- Add [Filter(Order=1)] metadata tags to attributes
Problem
I have a ASP.NET dynamic data site that has multiple filter controls built using metadata such as: ``` [ScaffoldTable(true), MetadataType(typeof(Fees.Metadata))] public partial class Fees { public class Metadata { [FilterUIHint("DateRange")] public object InvoiceDate; } { ``` How do I order these filters in a particular way. It seems very random. Can I use a metadata attribute or should I modify the page template, what's the go?