コード例 #1
0
 protected void PageInit()
 {
     if (!String.IsNullOrEmpty(Request["SignDocID"]))
     {
         PlaceHolder1.Controls.Clear();
         var QuestionDataList = _trainDetaiRepo.QueryQuestionDataBySignDocID(Request["SignDocID"]);
         QuestionDataList.All(row =>
         {
             PlaceHolder1.Controls.Add(new LiteralControl("<hr style='margin:6px;height:1px;border:0px;background-color:#D5D5D5;color:#D5D5D5;'/>"));
             PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
             //序號
             Label myLabel = new Label();
             myLabel.Text  = "";
             myLabel.Text  = row["serial_no"].ToString();
             myLabel.ID    = "Label" + row["serial_no"].ToString();
             //myLabel.BackColor = "#FFFFFF";
             myLabel.Width = 10;
             PlaceHolder1.Controls.Add(myLabel);
             PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
             //題目
             Label mylblName = new Label();
             mylblName.Text  = "";
             mylblName.Text  = row["CODENAME"].ToString();
             mylblName.ID    = "LabelName" + row["serial_no"].ToString();
             mylblName.Width = 300;
             PlaceHolder1.Controls.Add(mylblName);
             PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
             //答案
             if (row["ANSTYPE"].ToString() == "C")//填文字
             {
                 TextBox txtAns = new TextBox();
                 txtAns.Text    = "";
                 txtAns.ID      = "textbox" + row["serial_no"].ToString();
                 txtAns.Text    = row["ANS"].ToString();
                 //txtAns.TabIndex = (i + 1).ToString();
                 txtAns.TextMode = TextBoxMode.MultiLine;
                 txtAns.Width    = 500;
                 txtAns.Height   = 80;
                 PlaceHolder1.Controls.Add(txtAns);
             }
             else if (row["ANSTYPE"].ToString() == "N")//選分數
             {
                 TextBox txtAns = new TextBox();
                 txtAns.Text    = "";
                 txtAns.ID      = "textbox" + row["serial_no"].ToString();
                 txtAns.Text    = row["ANS"].ToString();
                 //txtAns.TabIndex = (i + 1).ToString();
                 //txtAns.TextMode = TextBoxMode.MultiLine;
                 txtAns.Width  = 50;
                 txtAns.Height = 50;
                 PlaceHolder1.Controls.Add(txtAns);
             }
             return(true);
         });
     }
 }
        protected void PageInit()
        {
            //編輯受訓心得
            if (!String.IsNullOrEmpty(Request["SignDocID_FK"]))
            {
                txterror.Text = "";
                PlaceHolder1.Controls.Clear();
                var QuestionDataList = _trainDetaiRepo.QueryQuestionDataBySignDocID(Request["SignDocID_FK"]);
                QuestionDataList.All(row =>
                {
                    PlaceHolder1.Controls.Add(new LiteralControl("<hr style='margin:6px;height:1px;border:0px;background-color:#D5D5D5;color:#D5D5D5;'/>"));
                    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
                    //序號
                    Label myLabel = new Label();
                    myLabel.Text  = "";
                    myLabel.Text  = row["serial_no"].ToString();
                    myLabel.ID    = "Label" + row["serial_no"].ToString();
                    //myLabel.BackColor = "#FFFFFF";
                    myLabel.Width = 10;
                    PlaceHolder1.Controls.Add(myLabel);
                    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
                    //題目
                    Label mylblName = new Label();
                    mylblName.Text  = "";
                    mylblName.Text  = row["CODENAME"].ToString();
                    mylblName.ID    = "LabelName" + row["serial_no"].ToString();
                    mylblName.Width = 400;
                    PlaceHolder1.Controls.Add(mylblName);
                    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
                    //答案
                    if (row["ANSTYPE"].ToString() == "C")//填文字
                    {
                        TextBox txtAns = new TextBox();
                        txtAns.Text    = "";
                        txtAns.ID      = "textbox" + row["serial_no"].ToString();
                        txtAns.Text    = row["ANS"].ToString();
                        //txtAns.TabIndex = (i + 1).ToString();
                        txtAns.TextMode = TextBoxMode.MultiLine;
                        txtAns.Width    = 500;
                        txtAns.Height   = 100;
                        PlaceHolder1.Controls.Add(txtAns);
                    }
                    return(true);
                });
            }
            //新增受訓心得
            if (!String.IsNullOrEmpty(Request["CLID"]) && !String.IsNullOrEmpty(Request["SID"]))
            {
                txterror.Text = "";
                PlaceHolder1.Controls.Clear();
                var QuestionDataList = _trainDetaiRepo.QueryQuestionDataByTableID("02");
                int i = 0;
                QuestionDataList.All(row =>
                {
                    PlaceHolder1.Controls.Add(new LiteralControl("<hr style='margin:6px;height:1px;border:0px;background-color:#D5D5D5;color:#D5D5D5;'/>"));
                    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp"));
                    //序號
                    Label myLabel = new Label();
                    myLabel.Text  = "";
                    myLabel.Text  = row["serial_no"].ToString();
                    myLabel.ID    = "Label" + row["serial_no"].ToString();
                    //myLabel.BackColor = "#FFFFFF";
                    myLabel.Width = 10;
                    PlaceHolder1.Controls.Add(myLabel);
                    //if (Int32.Parse(row["serial_no"].ToString()) < 10)
                    //{
                    //    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp"));
                    //}
                    //else
                    //{
                    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp;&nbsp;&nbsp"));
                    //}

                    //題目
                    Label mylblName = new Label();
                    mylblName.Text  = "";
                    mylblName.Text  = row["CODENAME"].ToString();
                    mylblName.ID    = "LabelName" + row["serial_no"].ToString();
                    mylblName.Width = 400;
                    PlaceHolder1.Controls.Add(mylblName);
                    PlaceHolder1.Controls.Add(new LiteralControl("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp"));
                    //答案
                    if (row["ANSTYPE"].ToString() == "C")//填文字
                    {
                        TextBox txtAns = new TextBox();
                        txtAns.Text    = "";
                        txtAns.ID      = "textbox" + row["serial_no"].ToString();
                        //txtAns.TabIndex = (i + 1).ToString();
                        txtAns.TextMode = TextBoxMode.MultiLine;
                        txtAns.Width    = 500;
                        txtAns.Height   = 100;
                        PlaceHolder1.Controls.Add(txtAns);
                    }
                    else if (row["ANSTYPE"].ToString() == "N")//選分數
                    {
                        RadioButtonList rblAns = new RadioButtonList();
                        rblAns.ID = "rbl" + row["serial_no"].ToString();
                        for (int j = 10; j >= 1; j--)
                        {
                            rblAns.Items.Add(new ListItem("&nbsp;&nbsp" + j.ToString() + "&nbsp;&nbsp", j.ToString()));
                        }
                        rblAns.RepeatColumns   = 10;
                        rblAns.RepeatLayout    = RepeatLayout.Flow;
                        rblAns.RepeatDirection = RepeatDirection.Vertical;
                        rblAns.Width           = 650;
                        //rblAns.Height = 80;

                        PlaceHolder1.Controls.Add(rblAns);
                        //txtAns.Width = 50;
                    }
                    //題號
                    Label QNOLabel   = new Label();
                    QNOLabel.Text    = "";
                    QNOLabel.Text    = row["QNO"].ToString();
                    QNOLabel.ID      = "QNOLabel" + row["serial_no"].ToString();
                    QNOLabel.Visible = false;
                    PlaceHolder1.Controls.Add(QNOLabel);
                    //題型
                    Label ANSTYPELabel   = new Label();
                    ANSTYPELabel.Text    = "";
                    ANSTYPELabel.Text    = row["ANSTYPE"].ToString();
                    ANSTYPELabel.ID      = "ANSTYPELabel" + row["serial_no"].ToString();
                    ANSTYPELabel.Visible = false;
                    PlaceHolder1.Controls.Add(ANSTYPELabel);

                    //PlaceHolder1.Controls.Add(new LiteralControl("<BR/>"));
                    i = i + 1;
                    return(true);
                });
            }
        }