protected void btnSubmit_Click(object sender, EventArgs e)
    {
        DataSet                  ds = new DataSet();
        SqlDataAdapter           da = new SqlDataAdapter();
        Dictionary <int, string> CorrectAnswers = new Dictionary <int, string>();
        Dictionary <int, string> UserAnswers = new Dictionary <int, string>();
        int Count = 0, TotalQuestion = 0;

        con = new SqlConnection(ConnectionString());
        try
        {
            command.Connection  = con;
            command.CommandText = "Select * from  ExamQuestions";
            da.SelectCommand    = command;
            con.Open();
            da.Fill(ds, "Examination");
            foreach (DataRow DRow in ds.Tables["Examination"].Rows)
            {
                CorrectAnswers.Add(Int32.Parse(DRow["QuestionId"].ToString()), DRow["Answer"].ToString());
            }

            foreach (DataListItem DList in DataList1.Items)
            {
                TotalQuestion++;
                RadioButton OptionA    = (RadioButton)DList.FindControl("rdbOptionA");
                RadioButton OptionB    = (RadioButton)DList.FindControl("rdbOptionB");
                RadioButton OptionC    = (RadioButton)DList.FindControl("rdbOptionC");
                RadioButton OptionD    = (RadioButton)DList.FindControl("rdbOptionD");
                HiddenField QuestionId = (HiddenField)DList.FindControl("hfQuestionId");
                UserAnswers.Add(Int32.Parse(QuestionId.Value), (OptionA.Checked == true) ? "A" : ((OptionB.Checked == true) ? "B" : ((OptionC.Checked == true) ? "C" : "D")));
            }

            foreach (KeyValuePair <int, string> UserAnsKeyValue in UserAnswers)
            {
                if (UserAnsKeyValue.Value == CorrectAnswers[UserAnsKeyValue.Key])
                {
                    Count++;
                }
            }
            Response.Redirect("~/Result.aspx?Result=" + Count + "&TotalQuestion=" + TotalQuestion);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            con.Close();
            command.Dispose();
        }
    }