protected void fmMain_DataBound(object sender, EventArgs e)
    {
        //System.Web.UI.HtmlControls.HtmlControl frmObj;
        Util_ucTextBox      oTxtBox;
        Util_ucCheckBoxList oChkBox;

        //「查詢」模式,即 ItemTemplate 範本
        if (fmMain.CurrentMode == FormViewMode.ReadOnly && fmMain.DataSource != null)
        {
            DataRow dr = ((DataTable)fmMain.DataSource).Rows[0];

            Label oLab = (Label)Util.FindControlEx(fmMain, "labKeywordResult");
            oLab.Text = "";
            if (!string.IsNullOrEmpty(dr["Keyword"].ToString()))
            {
                oLab.Text = Util.getStringJoin(Util.getArray(Util.getDictionary(_DicKeyword, dr["Keyword"].ToString().Trim().Split(',')), 1));
            }

            //Attach
            string strAttachID;
            string strAttachDownloadURL;
            string strAttachDownloadBaseURL = Util._AttachDownloadUrl + "?AttachDB={0}&AttachID={1}";

            // DocAttach Frame
            strAttachID          = string.Format(LegalSample._DocAttachIDFormat, dr["DocNo"].ToString());
            strAttachDownloadURL = string.Format(strAttachDownloadBaseURL, LegalSample._LegalSysDBName, strAttachID);

            //frmDocAttachQry物件不在FormView內,可直接存取
            frmDocAttachQry.Attributes["width"]  = "650";
            frmDocAttachQry.Attributes["height"] = "450";
            frmDocAttachQry.Attributes["src"]    = strAttachDownloadURL;
        }

        //「編輯」模式,即 EditItemTemplate 範本
        if (fmMain.CurrentMode == FormViewMode.Edit && fmMain.DataSource != null)
        {
            DataRow dr = ((DataTable)fmMain.DataSource).Rows[0];
            //設定欄位
            Util.setReadOnly("txtDocNo", true);
            ((CheckBox)Util.FindControlEx(fmMain, "chkIsRelease")).Checked = (dr["IsRelease"].ToString().ToUpper() == "Y") ? true : false;

            Util_ucCascadingDropDown oCascading = (Util_ucCascadingDropDown)Util.FindControlEx(fmMain, "ucCascadingKind");
            oCascading.ucServiceMethod = LegalSample._LegalDocKindServiceMethod;

            oCascading.ucCategory01 = "Kind1";
            oCascading.ucCategory02 = "Kind2";
            oCascading.ucCategory03 = "Kind3";

            oCascading.ucDefaultSelectedValue01 = dr["Kind1"].ToString();
            oCascading.ucDefaultSelectedValue02 = dr["Kind2"].ToString();
            oCascading.ucDefaultSelectedValue03 = dr["Kind3"].ToString();

            oCascading.ucDropDownListEnabled01 = true;
            oCascading.ucDropDownListEnabled02 = true;
            oCascading.ucDropDownListEnabled03 = true;
            oCascading.ucDropDownListEnabled04 = false;
            oCascading.ucDropDownListEnabled05 = false;

            oCascading.Refresh();

            oTxtBox            = (Util_ucTextBox)Util.FindControlEx(fmMain, "ucSubject");
            oTxtBox.ucTextData = dr["Subject"].ToString();
            oTxtBox.ucDispEnteredWordsObjClientID = Util.FindControlEx(fmMain, "dispSubject").ClientID;
            oTxtBox.ucMaxLength = LegalSample._SubjectMaxLength;
            oTxtBox.Refresh();

            oTxtBox            = (Util_ucTextBox)Util.FindControlEx(fmMain, "ucUsage");
            oTxtBox.ucTextData = dr["Usage"].ToString();
            oTxtBox.ucDispEnteredWordsObjClientID = Util.FindControlEx(fmMain, "dispUsage").ClientID;
            oTxtBox.ucMaxLength = LegalSample._UsageMaxLength;
            oTxtBox.Refresh();

            oChkBox = (Util_ucCheckBoxList)Util.FindControlEx(fmMain, "ucKeyword");
            if (oChkBox != null)
            {
                oChkBox.ucRangeMinQty       = _MinKeywordQty;
                oChkBox.ucRangeMaxQty       = _MaxKeywordQty;
                oChkBox.ucRangeErrorMessage = "<br>" + string.Format((string)GetLocalResourceObject("_KeywordExceedsMaxQty"), _MaxKeywordQty); //關鍵字最多選擇[{0}]項
                oChkBox.ucSourceDictionary  = _DicKeyword;
                oChkBox.ucSelectedIDList    = dr["Keyword"].ToString();
                oChkBox.Refresh();
            }

            oTxtBox            = (Util_ucTextBox)Util.FindControlEx(fmMain, "ucRemark");
            oTxtBox.ucTextData = dr["Remark"].ToString();
            oTxtBox.ucDispEnteredWordsObjClientID = Util.FindControlEx(fmMain, "dispRemark").ClientID;
            oTxtBox.ucMaxLength = LegalSample._RemarkMaxLength;
            oTxtBox.Refresh();

            //Attach
            string strAttachID;
            string strAttachAdminURL;
            string strAttachAdminBaseURL = Util._AttachAdminUrl + "?AttachDB={0}&AttachID={1}&AttachFileMaxQty={2}&AttachFileMaxKB={3}&AttachFileTotKB={4}&AttachFileExtList={5}";
            string strAttachDownloadURL;
            string strAttachDownloadBaseURL = Util._AttachDownloadUrl + "?AttachDB={0}&AttachID={1}";

            // DocAttach Frame
            strAttachID          = string.Format(LegalSample._DocAttachIDFormat, dr["DocNo"].ToString());
            strAttachAdminURL    = string.Format(strAttachAdminBaseURL, LegalSample._LegalSysDBName, strAttachID, LegalSample._DocAttachMaxQty, LegalSample._DocAttachMaxKB, LegalSample._DocAttachTotKB, LegalSample._DocAttachExtList);
            strAttachDownloadURL = string.Format(strAttachDownloadBaseURL, LegalSample._LegalSysDBName, strAttachID);

            //frmDocAttach物件不在FormView內,可直接存取
            frmDocAttach.Attributes["width"]  = "650";
            frmDocAttach.Attributes["height"] = "450";
            frmDocAttach.Attributes["src"]    = strAttachAdminURL;

            Button oBtn;
            oBtn = (Button)Util.FindControlEx(fmMain, "btnUpdate");
            if (oBtn != null)
            {
                oBtn.Text = RS.Resources.Msg_Confirm_btnOK;
            }

            oBtn = (Button)Util.FindControlEx(fmMain, "btnUpdateCancel");
            if (oBtn != null)
            {
                oBtn.Text = RS.Resources.Msg_Confirm_btnCancel;
            }
        }
    }