Solved

Dynamic questionnaire asp.net VB/ C#

Posted on 2009-04-03
6
5,269 Views
Last Modified: 2012-05-06
Hello!

Im working on a dynamic questionnaire for a company, but Im really starting to think if the approached ive chosen is the best way to go.

Im getting the data from a databasetable, filling a dataset in my application with the data recieved and then i loop it through and add the data in a placeholder.

Language: ASP.net VB or C# doesn't matter
----------
The table consists of radiobutton questions, checkradiobutton questions and might aswell have an image url.
I feel like its hard to create any nice design.ive used a reapeater with content templates  in previous works ive done. Is it possible somehow to do like a template for a radiobuttonlist, checkbuttonlist etc and just fill template with data instead of just adding like I do now with no actual idea of what is to be created.

Would be really glad if anyone could help me, give me some ideas /code on how to do it
Kindly regards Clooak
0
Comment
Question by:clooak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 10

Assisted Solution

by:MaxOvrdrv2
MaxOvrdrv2 earned 50 total points
ID: 24063144
well, you can always just define a single parameter as your drop-down or whatever you're building, and while looping through the dataset, for each row, reset the parameter, assign, and post...

dim row as datasetrow (or something like that)
dim itm as new listitem
dim dd as new dropdownlist
dd.Id="whatever"
for each row in ds.tables(0).rows
itm=new listitem
itm.value=row.item("fieldname")
itm.text=row.item("fieldname")
dd.items.add(itm)
next
me.containerID.items.add(dd)

something like this if you catch my drift. Unless i'm completely out of the picture with what i think you're trying to do ;)

M

0
 
LVL 9

Expert Comment

by:kprestage
ID: 24064083
We do something very similar and actually create User Controls for each "Question Type".  Then as we read in the questions from the database, we dynamically add the required control to the page in the proper order.  
0
 

Author Comment

by:clooak
ID: 24129620
kprestage, how would u check their answers later on if its i a usercontrol?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
kprestage earned 200 total points
ID: 24129750
Just create a property on the user control called "Answer" that returns the currently selected answer.  For example, lets say you have 2 types of questions "text" and "selectone".  For a text question, you will display a textbox for the user to enter an answer, for the selectone, it would be a dropdown box.  You create a property in the UserControl like this:


Public String Answer(){
get 
{
   switch (myquestiontype)
   {
       case "selectone":
          return DropDown1.Text;
       case "text":
          return TextBox1.Text;
   }
{
}

Open in new window

0
 

Author Comment

by:clooak
ID: 24129857
Okay thanks alot for the help, I guess I could just loop through the answers if i want several answers to be "correct"  So one control for each customfield etc for radiobuttonlist, checkbuttonlist and normal textfields right? Not every single one of them combined in to one?

It sounds like a really good idea, I will give it a try, thanks! Points will be handed out by the end of the day as soon as ive tried the advice
0
 
LVL 9

Expert Comment

by:kprestage
ID: 24129922
If you will have a question that allows multiple answers, you can simply change your "Answer" property to return a string[] array rather than just a string.  In our case, we actually return an Answer Class which has a description and generic<T> value property.  So our Answer Property actually returns List<Answer> rather than a string or string array.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question