コード例 #1
0
    //Events that occur when a user clicks the THAT button
    protected void btnThat_Click(object sender, EventArgs e)
    {
        int row = ((GridViewRow)((Control)sender).NamingContainer).RowIndex;

        Panel PnlMpeThis = (Panel)grid_quiz.Rows[row].FindControl("pnl_mpeThis");
        HiddenField hdfThisAns = (HiddenField)PnlMpeThis.FindControl("hdf_thisAns");
        PnlMpeThis.Visible = true;

        Guid QuestionID = Guid.Parse(hdfThisAns.Value.ToString());

        quizClass objLinq = new quizClass();
        string Answer = objLinq.getAnswer(QuestionID).ToString();

        //if THAT is the correct answer, display correct and increase the score
        if (Answer.Equals("THAT"))
        {
            Label lbl_ans = (Label)PnlMpeThis.FindControl("lbl_ans");
            lbl_ans.Text = "Correct!";
            score += 1;
        }
        //if THIS is the answer, display sorry
        else
        {
            Label lbl_ans = (Label)PnlMpeThis.FindControl("lbl_ans");
            lbl_ans.Text = "Sorry!";
        }
    }
コード例 #2
0
 //binding data to the GridView
 protected void _subBind()
 {
     quizClass objLinq = new quizClass();
     grid_quiz.DataSource = objLinq.getQues();
     grid_quiz.DataBind();
 }