Beispiel #1
0
        protected void Search(object sender, EventArgs e)
        {
            try
            {
                if (ddlExamName.SelectedValue == "Select Exam")
                {
                    throw new Exception("Select Exam Name");
                }
                DataTable dt = new DataTable();
                objML_StudentProfile.StudentName = Session["UserName"].ToString();
                objML_StudentProfile.ID          = txtSearch.Text != "" ? txtSearch.Text : null;
                if (objML_StudentProfile.ID == null)
                {
                    objML_StudentProfile.ID = "";
                }
                objML_StudentProfile.ExamName = ddlExamName.SelectedItem.Value != "" ? ddlExamName.SelectedItem.Value : null;

                if (rbtnMultiple.Checked == true)
                {
                    objML_StudentProfile.doctype = rbtnMultiple.Text;
                }
                else
                {
                    objML_StudentProfile.doctype = rbtnIndividual.Text;
                }
                dt = objBL_StudentProfile.BL_SerachQuestionInfo(objML_StudentProfile);
                if (dt.Rows.Count > 0)
                {
                    GrdCategory.DataSource = dt;
                    GrdCategory.DataBind();
                    int i = 0;
                    int y = 0;
                    foreach (GridViewRow row in GrdCategory.Rows)
                    {
                        Label lblTick       = (Label)row.FindControl("lbl");
                        Label lblStudentAns = (Label)row.FindControl("StudentAns");
                        Label lblCorrctAns  = (Label)row.FindControl("CorrectAns");
                        if (lblCorrctAns.Text == lblStudentAns.Text)
                        {
                            lblTick.Text = "✔";
                            i            = i + 1;
                        }
                        else
                        {
                            lblTick.Text = "❌";
                            y            = y + 1;
                        }
                    }
                    lblCorrect.Text     = i.ToString();
                    lblWrong.Text       = y.ToString();
                    lblTotalQus.Text    = dt.Rows.Count.ToString();
                    GrdCategory.Visible = true;
                }
                else
                {
                    GrdCategory.DataSource = dt;
                    GrdCategory.Visible    = false;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('No Data Found')", true);
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message.ToString() + "');", true);
            }
        }