Using User Controls in FormView Templates
I find repeating sets of controls for each of the FormView's EditItemTemplate, InsertItemTemplate, and ItemTemplate to be tedious and risky in terms of duplicate layout and code, etc. I would rather create a custom xxxDetails control and use that in every template, reducing the layout and layout of the code to one place.
However, this introduces several complications for data binding scenarios. Are there any advanced templates or how-to guides for using custom controls in these scenarios?
a source to share
Microsoft just added very much support for this in ASP.NET 4.0. It's called DynamicData. They added methods to all data controls called EnableDynamicData(type)
. ASP.NET has default templates, but you can make your own.
To use the built-in custom templates, simply add the DynamicData / Templates directory to your folder. Inside it, you can add type nesting and edit templates for all your data types. The default templates have built-in validators, so they are a great starting point!
Here is an example I put together for using custom controls in DynamicData templates . I used a slider to edit integers and CurrencyInput for money, etc.
If you can use ASP.NET 4.0, I would highly recommend doing it. Plus, even if you can't, you can still use the pre-built templates as a guide.
a source to share