?
Solved

Dynamic questionnaire asp.net VB/ C#

Posted on 2009-04-03
6
Medium Priority
?
5,311 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 200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Accepted Solution

by:
kprestage earned 800 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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