[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Dynamic questionnaire asp.net VB/ C#

Posted on 2009-04-03
6
Medium Priority
?
5,346 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Independent Software Vendors: 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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