Hi !
I am novice asp.net, C# developer. I am learning to build QUIZ app as seen from one of the videos on this site.
I have a Quiz Start form where I am initializing my session variables. the code is as under.
I have a public class Answer which has QuestionID, CorrectAnswer , UserAnswer, Result members.
in Page_Load of Quiz Start page i have written code as under.
ArrayList al = new ArrayList();
Session.Add("AnswerList", al);
Session.Add("QuizID", 1);
upon pressing StartQuiz Button on this QuizStartPage Questions.aspx page loads.
in Questions.aspx page I have a Question , 4 answers & a Next button.
on Click event of next button I have written
System.Data.DataRowView drv = (System.Data.DataRowView ) QuestionDetails.DataItem;
Answer ans = new Answer();
ans.QuestionID = drv["QueID"].ToString();
ans.CorrectAnswer = drv["CorrectAns"].ToString();
ans.UserAnswer = UserAns.SelectedValue.ToString();
Arraylist al = (ArrayList) Session["AnswerList"];
al.Add(ans);
Session.Add("Answerlist", ans);
.
.
.When I run this & click on trhe next button I can see my question & 4 options. When I click on next it displays second question& its 4 probabale ansers but now when I click on next button, I get "Unable to cast object of type 'Answer' to type 'System.Collections.ArrayList'. Error.
Kindly let me know where I am wrong. What do i need to rectify.
Tralsi