I am working in Fast Survey Project!!
i have no time for design a database and all these things ,i have only one table and i have to fill the answers , i have to finish it within two days.
the problem is I have more than 50 questions and i divided them into 3 groups , i putted each question group in User Control, and i am trying to save the values from each user control.
i want to save theme temporarily after each user control and when the user reach the last user control and click finish button it should save all the answers one time .
so is there any idea?? I was thinking to use something like global file !!
but i don't whether it works or not but i am working on it now and i hope to find any idea from you people.
You can temporarily save in session:
var survey = new Survey();
Survey.Name = textBoxName.Text;
Session["answer"] = survey.
Then later in all forms you can use:
var survey = Session["answer"] as Survey;
if (survey == null)
//error, redirect to start
Where Survey class is class, which contains all survey info.
Other example,
//Form1, question 1
List<string> survey = new List<string>();
survey.Add(textBox1.Text);
Session["survey"] = survey;
//Form2, question2
var survey = Session["survey"] as List<string>;
survey.Add(textBox1.Text);
//Form...n... final save
var survey = Session["survey"] as List<string>;
for(int i=0; i< survey.Count;i++)
{
SaveAnswer("someId", i, survey(i));
}
Here is one solution
If you want to display a page with a group of up to three question on each page, then it becomes slightly more complicated. The question page would then be referenced with the groupID instaed.
If you only have 2 days for your implementation, then I would certainly settle for the simple one-question-per-page solution.
This is easily solvable through UserControl public properties.
Here is how i would solve this:
// this dictionary will eventually be serialized and kept in session
// throughout the whole Q&A session
var questionsAndAnswers = new Dictionary();
foreach(var control in MyUserControls)
{
questionsAndAnswers.Add(control.Question, control.Answer);
}
this.Session["q&a"] = questionsAndAnswers;
Something like that should do the work.
The main point here is the emphasis on getting the needed information through exposed properties from your child controls (the same concept can be applied on any parent/child level in your code).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.