This is a migrated thread and some comments may be shown as answers.

How to Create a Dynamic Questionnaire

1 Answer 717 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vuyiswa
Top achievements
Rank 2
Vuyiswa asked on 01 Dec 2011, 03:49 PM
Good Day Fellows 

i have a Dynamic Questionnaire that is created using dynamic data from the Database. My data in the Database contains the fields like 

QuestionID - Primary key
Question  - The Question Text
Answer - The Answer 
Required - This is a Validation , i used this to enable the Required validator in asp.net
DataType - This is the Datatype, it can be a Heading also. 
ReadOnly - This check if that Question is a Read-only , This happens most of the time , when it is a Calculated Field, meaning its                       values depends on other fields values.
Order -   This is the order the Questions will appear 
Section  - This is the section, So the Questions are Grouped. Normaly in Page1 you will have Questions for Section 1.......
Deleted- This is a bit Field , its either 1 or 0 , 1 is active, so this helps be to Filter only active Questions
QuestionType- This is the Type of Control the Data should be Presented with, It can be a Dropdown ,checkbox or textbox..
QT_ID - There can be many Templates of the Question , this makes sure we use the Correct Template for the Questionnaire

So with this kind of Data , i want to use know , what Telerik Control can i use to achieve this.

Thanks 
  

1 Answer, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 01 Dec 2011, 08:56 PM
Any list style control will work for this.

RadGrid seems to get the most love and has the most well tested features. I recently implement this system in a TreeList control because my Sections could be nested. I had some issues, and a features was recently added to the latest release to fix my problem.

Your biggest hurdle is overcoming the complexities that arise when you dynamically add new controls into ASP.net's control hierarchy. Once you add it dynamically, you are responsible for re-adding it on post-back. Fail to do this properly and you'll lose view state for the sub controls as well as events. Also, when to add it ( in which event / cycle state) is important. And if that's not enough, when you set it's ID value can have consequences as well. In some cases this:

theNewcontrol.ID = "txtAnswer";
phPlaceholder.Controls.Add(theNewControl);

has different consequences than this:

phPlaceholder.Controls.Add(theNewControl);
theNewcontrol.ID =
"txtAnswer";

Good luck. Start small with a bare-bones solution, and work only one dynamically created the control. ALSO, be sure to have a way to test post back as you experiment. Often times, dynamic controls seem easy ( and appear to 'work')  until you think your 'finished' and cause a post back, only to realize you have no view state or worse, no events on the dynamic control ( text changed) fired.

It gets to be even more fun when you have a Dynamic Control with additional dynamic controls.

Tags
General Discussions
Asked by
Vuyiswa
Top achievements
Rank 2
Answers by
Frank
Top achievements
Rank 1
Share this question
or