Dear All,
I have a method where i would like to retrieve the total number of Skipped, Correct, and Wrong answers submited by User. How to find the value of "TotalSkipped"; "TotalCorect"; and "TotalWrong" in this method?
protected void SubmitTest_Click(object sender, EventArgs e)
{
PanelAllQuestionsAndRadioButtons.Visible = false;
PanelSubmitButton.Visible = false;
SqlConnection myconn;
SqlCommand mycomm;
myconn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionQuiz"].ConnectionString);
myconn.Open();
int score = 0;
int Totalskipped = 0;
int TotalCorect = 0;
int totalWrong = 0;
// PanelResultat.Controls.Add(new LiteralControl("<br>"));
int y = studentAnswer.Count + 1;
int x = 1;
foreach (string p in studentAnswer)
{
RadioButtonList myrblist2 = new RadioButtonList();
myrblist2 = (RadioButtonList)PanelAllQuestionsAndRadioButtons.FindControl("RadioButtonList" + x);
Label mylabel = new Label();
mylabel.ID = "Label" + y.ToString();
if (myrblist2.SelectedIndex < 0)
{
mylabel.Text = "You have skipped question no." + x + ", Correct answer is " + p;
PanelResultat.Controls.Add(mylabel);
}
else
{
if (myrblist2.SelectedItem.ToString() == p)
{
mylabel.Text = "Your question no." + x + " is correct";
PanelResultat.Controls.Add(mylabel);
score += correctmark;
}
else
{
mylabel.Text = "Your question no." + x + " is incorrect, Correct answer is " + p;
PanelResultat.Controls.Add(mylabel);
score -= negativemark;
}
}
x++;
y++;
PanelResultat.Controls.Add(new LiteralControl("<br>"));
lblscore.Text = "Final Score is " + score.ToString();
lblTotalSkipped.Text = "Total Skiped is " + Totalskipped.ToString();
lblTotalCorect.Text = "Total Correct is " + TotalCorect.ToString();
lblTotalWrong.Text = "Total Wrong is " + totalWrong.ToString();
}
myconn.Close();
Many thanks in advance