Dynamic Control load from Database

Joined
Dec 21, 2009
Messages
24
Location
India
Programming Experience
1-3
hi ,
this is my scenario. There are two users . User A and User B . User A assign himself some controls on the aspx page and once the button is clicked the controls should be stored in database and the next page should display the controls from database so as to enter data. for ex user a selects 1 textbox, 1 label and the next page should display these. kindly provide me a solution .

Thanks in advance
 
You can store the type name and assembly name of the control in the database as a string, and on your next page instansiate your control from its type string as follows:

Page 1:
For Each ctrl as Control in Me.Controls
' Save assembly name and control name
WriteToDatabase(ctrl.GetType().Assembly.FullName, ctrl.GetType().FullName);
Next

Page 2:
For Each row as DataRow in ctrlRows
Me.Controls.Add(Activator.CreateInstance(Assembly.Load(row("AssemblyName")).GetType( _
row("ControlName"), true)))
Next
 
Back
Top