I would like to dynamically generate a form from a database in ASP.NET, what is the best approach? Are there any built in functionalities I can use?
I will have database tables to represent the panels and their names, then for each panels, it contains the different fields and their types (Combos, Textboxes, etc..).
Please advice, thank you.
Note: I have to use Telerik Ajax controls for the form generation
Have a look at Dynamic Data.
I recently found out about it and it’s already saved me a lot of time.
Update:
Apologies – having reread the question, I don’t think this is what you were after.
If you want to dynamically generate the form based on the records in your database, you may have to write your own engine.
A couple of suggestions though:
Update: more info on reflection
Put simply, reflection is when you find out about details of an assembly at runtime. In this case, I suggest using reflection to load a control based on the information in your database.
So if you had a record in your database similar to the following:
You could use some code like the following to generate the control on the page (note that it’s untested):
There is a really good page outlining how to do this here. It looks to be pretty much what you’re after.