Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 29, 2012 06:55 PM by Ophelia
Apr 05, 2012 12:03 PM|LINK
Why not use a "Prevous Question" Button?
Also please read above...I don't want to be rude or something but i explain above that my problem is not about displaying the questions randomly or something like that. I have already created a page where the user gets test depending on his level.
Apr 05, 2012 12:08 PM|LINK
Ah, you are using ListView without Edit/Update. The example I made has GridView use Edit/Update to update the data I keep in ViewState. In your case there is no Update event. However, you can save the data in the PageIndexChanging handler, right before the
page is actually changed.
You can do that by getting the RadioButtons from the Item in the current Page. You will need code to store them. And restore values when the user gets back to a question already answered.
Apr 05, 2012 12:26 PM|LINK
Thank you so much for your answer. I will try what you said, but i think -after some search i did- that the GroupName and Id of the radiobutton is going to be a problem. For example on Page1 i have Question1, Answer1...., on Page2 Question2, Answer1......
etc The ID's of the radiobuttons are the same in every page. So how can i keep the data? Maybe something like that? http://www.codeproject.com/Articles/7960/How-to-group-RadioButtons
Apr 05, 2012 12:58 PM|LINK
Actually, the GroupName isn't used for the data. Instead, it determines the groups within which only one can be selected in the browser. If you have only one question per page, that will work fine.
To determine which choice was made, look up the RadioButtons (with FindControl) and see which one is Checked. Remeber the answers that were given as key-value pairs. Key being the question-id. Value being the answer-id/-index.
As an alternative you may want to look at using a RadioButtonList. It needs a list of options as DataSource. Get/set the selection through SelectedIndex.
This works different from what you already have. If the data-structure behind it has a list of options, it is worth looking into. If there are always 4 options that are in the question, it is probably not worth looking into.
Apr 05, 2012 04:09 PM|LINK
Ok i will try this tonight. I think it is going to be a looong night. Do you have any code example or something?
I will get back to you with my progress...
Apr 09, 2012 01:22 PM|LINK
I haven't looked at it yet because i had some work to do. I will look at it and i will let you know.
Apr 09, 2012 07:11 PM|LINK
If I were you, I would use the asp:Wizard.
It will handle all of your prev next finish, you'll have more control and you can define the controls easier
Apr 09, 2012 07:19 PM|LINK
Actually my first though was the wizard but i think that i had an issue with creating the steps dynamically depending on how many questions are in the quiz (the number of questions varies.) I think that i made a post about this in 2011. The Quiz was a university
project in 2011 which i complete and now i am trying to make it better.
Apr 29, 2012 06:55 PM|LINK
So i decided to use a wizard but i have a few problems. i will make a new post.