示例#1
0
    //绑定题目
    protected void BindTitle(string sortId, int index)
    {
        Param = "&sortId=" + sortId;  //动态修改传递参数的值
        List <StuExamTopic> topics = stuExamBll.GetExamTopicBySortId(studentId, examId, sortId);

        int length = topics.Count();

        if (index > length - 1)
        {
            Response.Redirect("ExamMain.aspx");
        }

        pds.DataSource       = topics;
        pds.CurrentPageIndex = index;

        string nowTitleId = topics[index].TopicId.ToString();

        //设置当前题目的序号为红色
        for (int i = 0; i < AllTitleList.Items.Count; i++)
        {
            Repeater theTitleList = (Repeater)AllTitleList.Items[i].FindControl("theTitleList");
            for (int j = 0; j < theTitleList.Items.Count; j++)
            {
                string thetitleId = ((Label)theTitleList.Items[j].FindControl("TopicId")).Text;
                if (thetitleId == nowTitleId)
                {
                    ((HyperLink)theTitleList.Items[j].FindControl("HyperLink1")).Attributes.CssStyle.Value = "background-color:red";
                }
            }
        }
        Single.Visible    = true;
        Single.DataSource = pds;
        Single.DataBind();
    }
示例#2
0
    //所有题型
    protected void AllTitleList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Label  SortIdLabel = (Label)e.Item.FindControl("SortId");
        string sortId      = SortIdLabel.Text.ToString();

        Repeater TheTitleList    = (Repeater)e.Item.FindControl("theTitleList");
        Label    WaitNumberLabe  = (Label)e.Item.FindControl("WaitNumber");  //已做题目数量
        Label    TotalNumberLabe = (Label)e.Item.FindControl("TotalNumber"); //题目数量

        Flag2++;
        if (Flag2 == 1)
        {
            Param = "&sortId=" + SortIdLabel.Text;
        }
        if (Flag == 1 && Flag2 == 1)
        {
            BindTitle(sortId, 0); //第一次进入该页面时显示第一题
        }

        StuExamBLL stuExamBll = new StuExamBLL();

        int hasDoTopic = 0; //已做的题目数量

        List <StuExamTopic> stuExamTopics = stuExamBll.GetExamTopicBySortId(studentId, examId, sortId);

        foreach (var item in stuExamTopics)
        {
            if (item.StuAnswer != null && item.StuAnswer.Trim() != "")
            {
                hasDoTopic++;
            }
        }
        WaitNumberLabe.Text  = hasDoTopic.ToString();
        TotalNumberLabe.Text = stuExamTopics.Count().ToString();

        TheTitleList.DataSource = stuExamTopics;
        TheTitleList.DataBind();
    }