//���������Զ������Ծ�
 protected void BindData()
 {
     DataBase database = new DataBase();//����DataBase�����
     string GridView1StrSQL = "select * from SingleProblemmr";//���ݲ������ò�ѯ��ѡ��Sql���
     DataSet myds1 = database.GetDataSetSql(GridView1StrSQL);//����DataBase�෽��GetDataSetSql������ѯ����
     GridView1.DataSource = myds1.Tables[0].DefaultView;//Ϊ��ѡ��GridView�ؼ���������Դ
     GridView1.DataBind();//������
     string GridView2StrSQL = "select * from MultiProblemmr";//���ݲ������ò�ѯ��ѡ��Sql���
     DataSet myds2 = database.GetDataSetSql(GridView2StrSQL);//����DataBase�෽��GetDataSetSql������ѯ����
     GridView2.DataSource = myds2.Tables[0].DefaultView;//Ϊ��ѡ��GridView�ؼ���������Դ
     GridView2.DataBind();//������
     string GridView3StrSQL = "select * from JudgeProblemmr";//���ݲ������ò�ѯ�ж���Sql���
     DataSet myds3 = database.GetDataSetSql(GridView3StrSQL);//����DataBase�෽��GetDataSetSql������ѯ����
     GridView3.DataSource = myds3.Tables[0].DefaultView;//Ϊ�ж���GridView�ؼ���������Դ
     GridView3.DataBind();//������
     string GridView4StrSQL = "select * from FillBlankProblemmr";//���ݲ������ò�ѯ�����Sql���
     DataSet myds4 = database.GetDataSetSql(GridView4StrSQL);//����DataBase�෽��GetDataSetSql������ѯ����
     GridView4.DataSource = myds4.Tables[0].DefaultView;//Ϊ�����GridView�ؼ���������Դ
     GridView4.DataBind();//������
     string GridView5StrSQL = "select * from QuestionProblemmr";//���ݲ������ò�ѯ�ʴ���Sql���
     DataSet myds5 = database.GetDataSetSql(GridView5StrSQL);//����DataBase�෽��GetDataSetSql������ѯ����
     GridView5.DataSource = myds5.Tables[0].DefaultView;//Ϊ�ʴ���GridView�ؼ���������Դ
     GridView5.DataBind();//������
 }
    //��ʼ���Ծ�������ݿ��н�����ȡ��
    protected void PaperData()
    {
        string userid = Request.QueryString["UserID"].ToString();
        paperid = int.Parse(Request.QueryString["PaperID"].ToString());

        DataBase DB = new DataBase();

        DataSet ds = DB.GetDataSetSql("select * from [UserAnswermr] where UserID='" + userid + "'");
        DataRow[] row = ds.Tables[0].Select();
        foreach (DataRow rs in row)
        {
            lblExamtime.Text = rs["ExamTime"].ToString();
        }

        SqlParameter[] Params1 = new SqlParameter[3];
        Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid);
        Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "��ѡ��");
        Params1[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid);
        DataSet ds1 = DB.GetDataSet("Proc_UserAnswermr", Params1);
        if (ds1.Tables[0].Rows.Count > 0)
        {
            GridView1.DataSource = ds1;
            GridView1.DataBind();
            ((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text;
        }

        SqlParameter[] Params2 = new SqlParameter[3];
        Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid);
        Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "��ѡ��");
        Params2[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid);
        DataSet ds2 = DB.GetDataSet("Proc_UserAnswermr", Params2);
        if (ds2.Tables[0].Rows.Count > 0)
        {
            GridView2.DataSource = ds2;
            GridView2.DataBind();
            ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text;
        }

        SqlParameter[] Params3 = new SqlParameter[3];
        Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid);
        Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "���");
        Params3[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid);
        DataSet ds3 = DB.GetDataSet("Proc_UserAnswermr", Params3);
        if (ds3.Tables[0].Rows.Count > 0)
        {
            GridView3.DataSource = ds3;
            GridView3.DataBind();
            ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text;
        }

        SqlParameter[] Params4 = new SqlParameter[3];
        Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid);
        Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "�����");
        Params4[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid);
        DataSet ds4 = DB.GetDataSet("Proc_UserAnswermr", Params4);
        if (ds4.Tables[0].Rows.Count > 0)
        {
            GridView4.DataSource = ds4;
            GridView4.DataBind();
            ((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text;
        }

        SqlParameter[] Params5 = new SqlParameter[3];
        Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid);
        Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "�ʴ���");
        Params5[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid);
        DataSet ds5 = DB.GetDataSet("Proc_UserAnswermr", Params5);
        if (ds5.Tables[0].Rows.Count > 0)
        {
            GridView5.DataSource = ds5;
            GridView5.DataBind();
            ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label21")).Text;
        }

        if (GridView1.Rows.Count > 0)
        {
            int score1 = 0;
            int singlemark = int.Parse(((Label)GridView1.Rows[0].FindControl("Label4")).Text);//ȡ����ѡ���ÿ���ֵ
            foreach (GridViewRow dr in GridView1.Rows)
            {
                if (((Label)dr.FindControl("Label3")).Text.Trim() == "A")
                {
                    ((RadioButton)dr.FindControl("RadioButton1")).Checked = true;
                }
                else if (((Label)dr.FindControl("Label3")).Text.Trim() == "B")
                {
                    ((RadioButton)dr.FindControl("RadioButton2")).Checked = true;
                }
                else if (((Label)dr.FindControl("Label3")).Text.Trim() == "C")
                {
                    ((RadioButton)dr.FindControl("RadioButton3")).Checked = true;
                }
                else if (((Label)dr.FindControl("Label3")).Text.Trim() == "D")
                {
                    ((RadioButton)dr.FindControl("RadioButton4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label3")).Text.Trim() == ((Label)dr.FindControl("Label23")).Text.Trim())
                {
                    score1 = score1 + singlemark;
                    sinScore.Text = Convert.ToString(score1);
                }
            }
        }

        if (GridView2.Rows.Count > 0)
        {
            int score2 = 0;
            int multimark = int.Parse(((Label)GridView2.Rows[0].FindControl("Label8")).Text);//ȡ����ѡ��ÿ���ֵ
            foreach (GridViewRow dr in GridView2.Rows)
            {
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "A")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "B")
                {
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "C")
                {
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "D")
                {
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "AB")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "AC")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "AD")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "BC")
                {
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "BD")
                {
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "CD")
                {
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABC")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABD")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "ACD")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABCD")
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }
                if (((Label)dr.FindControl("Label7")).Text.Trim() == ((Label)dr.FindControl("Label27")).Text.Trim())
                {
                    score2 = score2 + multimark;
                    mulScore.Text = Convert.ToString(score2);
                }
            }
        }

        if (GridView3.Rows.Count > 0)
        {
            int score3 = 0;
            int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text);//ȡ���ж���ÿ���ֵ
            foreach (GridViewRow dr in GridView3.Rows)//���ж���ÿ������ж��û�ѡ���
            {
                if (bool.Parse(((Label)dr.FindControl("Label11")).Text.Trim()))
                {
                    ((CheckBox)dr.FindControl("CheckBox5")).Checked = true;
                }
                else
                {
                    ((CheckBox)dr.FindControl("CheckBox6")).Checked = true;
                }
                if (((Label)dr.FindControl("Label11")).Text.Trim() == ((Label)dr.FindControl("Label41")).Text.Trim())
                {
                    score3 = score3 + judgemark;
                    judScore.Text = Convert.ToString(score3);
                }
            }
        }
        //ȡ�������ÿ���ֵ
        if (GridView4.Rows.Count > 0)
        {
            int score4 = 0;
            int fillmark = int.Parse(((Label)GridView4.Rows[0].FindControl("Label17")).Text);
            foreach (GridViewRow dr in GridView4.Rows)//�������ÿ������ж��û�ѡ���
            {
                string str = "";
                str = ((TextBox)dr.FindControl("TextBox1")).Text.Trim();
                if (str == ((Label)dr.FindControl("Label26")).Text.Trim())
                {
                    score4 = score4 + fillmark;
                    filScore.Text = Convert.ToString(score4);
                }
            }
        }
    }