c# - Dynamic Form Generation in ASP.NET -
I want to dynamically create a form from a database in ASP.NET, what's the best way? Can a Functionality be Used?
I will have database tables to represent the panels and their names, then for each panel, it includes different fields and their types (combos, text boxes, etc.). .
Please advise, thank you.
Note: I have to use the Teleik Ajax control for form generation
Have a look.
I've recently learned about it and it has already saved me lot
updates:
Apologies - Reading the question again, I do not think this is what was done after you.
If you want to dynamically generate the form based on the records in your database, you may have to type your own engine.
Some suggestions though:
- I want to use reflection to load control rather than big case statement, in this way you dynamically involve new assembly You can add different control types, you do not have to type the new code.
- Make sure you include a way to control the display order in your database. I think that you want to use a different table for each panel of control, I should advise against it because of the performance order problem. If you have a foreign key reference with a list of panels and a table + panel with a list of data tables, you will be able to place them on the page in an estimate and controllable way.
Update: More information about reflection
Just keep in mind, the reflection occurs when you talk about the assembly details on the runtime Find out, in this case, I suggest using reflection to load the control based on information in your database.
So if you had a record in your database like the following:
FieldName DataType Display Controller PerformanceProperty --------------- ------------------------------------------------ ----------------- The first name System.String System.Web.UI.WebControls.TextBox allows you to generate control on page you can use a code (note that this is Andekshit):
PageItem pageItems "array foreach" PageItem in a database record "(pageItems p) {// get the type and c O Type controlType = System.Type.GetType (p.DisplayControl) PropertyInfo [] controlPropertiesArray = controlType.GetProperties (); // object object control = Activator. Bnaaainstens (control type); // ( "data" control for this item , null) if {PropertyInfo controlProperty) property foreach (controlPropertiesArray (controlPropertiesArray.Name == p.DisplayProperty) look set controlProperty.SetValue matching properties {// control;}} // if (Sorry, look up that The lack of time to do) generated the page control using LoadControl A very good one. The way to do this is not the outline page. It looks pretty much what you're after.
Comments
Post a Comment