Creating Questions Dynamically

T

Tex

I am writting a survey system web application. I am using ASP.Net 2,
C# and MS SQL 2005. I am able to store surveys and questions
associated to the surveys just fine. The problem I am having is
Dynamically creating a survey on a page. I have read some MS articles
on dynamic creation of web forms and have been able to create one
question on a page. I am not sure how to create a variable amount of
different types(radio button lists, text boxes etc.) of questions on a
single page. Also I need to figure out how to name things uniquely so
I can go back after a submit click and gather the results.

Any advice or ideas would be appreciated.

Thanks
 
E

Eliyahu Goldin

Creating controls dynamically is not a good design idea. Rather you should
prepare a question template with all possible controls and operate their
visibility properties in run time.

Eliyahu
 
F

Flinky Wisty Pomm

I knocked one of these up a couple of weeks ago to run on PDAs and a
web app - we use an Xml document to represent the questionnaire and its
structure, then transform that document into ASP.Net tags or control
templates. Loading the generated tags takes a tiny amount of code.

Basic technique is demonstrated here
http://www.codeproject.com/aspnet/xmlxsltransformer.asp
 
P

Progman

use the wizard if you have a fixed number of questions
you could also load the same page with different parameters
using the passed parameter, query from a questions table.

have fun
 
R

Robbe Morris [C# MVP]

That is a horrible idea. I spend my days writing
rather complex survey generation and data mining
applications. You really do need to create
these dynamically.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp
 
R

Robbe Morris [C# MVP]

This article is off topic but is dead on for how
to create controls dynamically.

http://www.eggheadcafe.com/articles/extendtextboxviewstate.asp

On a side note, do NOT combine your UI
oriented display properties with those
of the question and answer tables. You
need to create UI placement tables to
store how you intend to render your
survey at runtime and relate your
questions and answers to those tables.

Trust me on this one...I make a living
writing rather complex survey applications
for Gartner (IT research firm). So, I've
been where you are now and know
the problems with not doing this
properly.
 
T

Tex

I believe that the best way to do this is dynamic controls, but I don't
understand the statement about not combining UI properties with q&a
tables?

Also, when you say placement table is that what is used in the example
you supplied?

I did download the example you supplied and walked through the code. I
have a decent idea what to do now. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top