Solved

Dynamic questionnaire asp.net VB/ C#

Posted on 2009-04-03
6
5,200 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

810 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