protected override void OnPreRender(EventArgs e)
        {
            if (!IsPostBack)
            {
                string[]  colAlias  = SampleConstants.BoundDataColumns;
                ArrayList ThemeList = new ArrayList();
                ThemesAndModifiers.FillThemeNames(ThemeList);

                DropDownList1.Items.Clear();
                DropDownList1.DataSource = ThemeList;
                DropDownList1.DataBind();

                // Prepare CheckBoxes, RadioButtons and note label contents.
                CheckBoxList1.DataSource = colAlias;
                CheckBoxList1.DataBind();
                CheckBoxList1.Visible = this.IsCheckBoxListVisible(ThemeList[0] as string);

                RadioButtonList1.DataSource = colAlias;
                RadioButtonList1.DataBind();
                RadioButtonList1.Visible = this.IsRadioButtonListVisible(ThemeList[0] as string);

                Label2.Visible = this.IsNoteLabelVisible(ThemeList[0] as string);
                Label2.Text    = "Please select two columns from below checkboxes.";

                DropDownList1.Items.Clear();
                DropDownList1.DataSource = ThemeList;
                DropDownList1.DataBind();
            }
        }
 public bool LlenarRadioBL_Web( RadioButtonList Generico )
 {
     if ( ! Validar() )
             return false;
         clsConexionBD objConexionBd = new clsConexionBD( strApp );
         try
         {
             objConexionBd.SQL = strSQL;
             if ( ! objConexionBd.LlenarDataSet( false ) )
             {
                 strError = objConexionBd.Error;
                 objConexionBd.CerrarCnx();
                 objConexionBd = null;
                 return false;
             }
             Generico.DataSource = objConexionBd.DataSet_Lleno.Tables[0];
             Generico.DataValueField = strCampoID;
             Generico.DataTextField = strCampoTexto;
             Generico.DataBind();
             objConexionBd.CerrarCnx();
             objConexionBd = null;
             return true;
         }
         catch (Exception ex)
         {
             strError = ex.Message;
             return false;
         }
 }
 /// <summary>
 /// 绑定下拉列表(数据显示控件或者源数据集不存在都会引发异常)
 /// </summary>
 /// <param name="rbtnl">数据显示控件</param>
 /// <param name="ds">数据集</param>
 /// <param name="DataTextField">文本数据源</param>
 /// <param name="DataValueField">值数据源</param>
 /// <param name="hasTopItem">bool,是否有默认第一项</param>
 /// <param name="topItemText">第一项文本</param>
 /// <param name="topItemValue">第一项值</param>
 public static void Bind(System.Web.UI.WebControls.RadioButtonList rbtnl, DataSet ds, string DataTextField, string DataValueField, bool hasTopItem, string topItemText, string topItemValue)
 {
     if (rbtnl != null)
     {
         if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             rbtnl.ClearSelection();
             rbtnl.Items.Clear();
             rbtnl.DataTextField  = DataTextField;
             rbtnl.DataValueField = DataValueField;
             rbtnl.DataSource     = ds.Tables[0].DefaultView;
             rbtnl.DataBind();
             if (hasTopItem)
             {
                 ListItem lit = new ListItem(topItemText, topItemValue);
                 rbtnl.Items.Insert(0, lit);
             }
         }
         else
         {
             throw new Exception("源数据集不存在");
         }
     }
     else
     {
         throw new Exception("数据控件不存在");
     }
 }
Exemple #4
0
        protected void PollExampleBind()
        {
            dbUtil = new DBLib();

            string fieldNames, tableName, whereClause, orderBy;

            fieldNames  = "exNbr,example";
            tableName   = "t_PollEX";
            whereClause = "poll_id =" + this.poll_id;
            orderBy     = "exNbr";
            //실제쿼리실행
            drPoll = dbUtil.Select_DR(fieldNames, tableName, whereClause, orderBy);

            if (drPoll.HasRows)
            {
                rblExamples.DataSource = drPoll;

                rblExamples.DataValueField       = "exNbr";
                rblExamples.DataTextField        = "example";
                rblExamples.DataTextFormatString = "{0}";
                rblExamples.DataBind();
            }
            else
            {
                rblExamples.ToolTip = "예제가 없습니다.";
            }
            drPoll.Close();
        }
Exemple #5
0
        /// <summary>
        /// RadioButtonLis快速绑定

        /// </summary>
        /// <param name="rbtlControls">RadioButtonLis控件</param>
        /// <param name="dt">DataTable表</param>
        /// <param name="strName">要绑定的Text列</param>
        /// <param name="strValue">要绑定的Value列</param>
        public static void RadioButtonListDataBind(System.Web.UI.WebControls.RadioButtonList rbtlControls, DataTable dt, string strName, string strValue, bool isDisplay)
        {
            rbtlControls.DataSource     = dt;
            rbtlControls.DataTextField  = strName;
            rbtlControls.DataValueField = strValue;
            rbtlControls.DataBind();
            if (isDisplay)
            {
                dt.Dispose();
            }
        }
Exemple #6
0
    public void FillRadioListBox(System.Web.UI.WebControls.RadioButtonList lst, ref tblAttributes objtblAttr, bool blnAutoPostBack, int intSelectedId)
    {
        SqlDataReader objReader = null;

        try
        {
            DBConnectionOpenDynamic(0);

            FillDataReader obj = new FillDataReader();
            if ((objReader != null))
            {
                if (objReader.IsClosed == false)
                {
                    objReader.Close();
                }
            }
            objReader        = obj.fn_FillDataReader(ref objtblAttr, con);
            lst.AutoPostBack = blnAutoPostBack;
            if (intSelectedId != 0)
            {
                lst.SelectedValue = Convert.ToString(intSelectedId);
            }
            lst.DataSource     = objReader;
            lst.DataTextField  = objtblAttr.strDisplayField;
            lst.DataValueField = objtblAttr.strValueField;
            lst.RepeatColumns  = objtblAttr.intColumn;
            //lst.RepeatDirection = objtblAttr.strRepeateDirection;
            lst.DataBind();
        }
        catch (Exception ex)
        {
            if (objtblAttr.strProc != "sp_getIUDErrorDetails")
            {
                saveErrorDetails(objtblAttr.strQuery, objtblAttr.strProc, returnStringFromArr(objtblAttr.strOutputStringArr), HttpContext.Current.Request.RawUrl, "RLB", ex.Message);
            }
        }
        finally
        {
            if (con != null)
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            if (objReader != null)
            {
                if (objReader.IsClosed == false)
                {
                    objReader.Close();
                }
            }
        }
    }
 public static void FillDataToRadioButtonList(RadioButtonList control, string table, string dataTextField, string dataValueField)
 {
     opendata();
     string strCommand = "SELECT " + dataTextField + ", " + dataValueField + " FROM " + table;
     sqladapter = new SqlDataAdapter(strCommand, sqlconn);
     mydata = new DataSet();
     sqladapter.Fill(mydata, strCommand);
     control.DataSource = mydata;
     control.DataTextField = dataTextField;
     control.DataValueField = dataValueField;
     control.DataBind();
     closedata();
 }
        public static void createItemAdPos(ref RadioButtonList rbl)
        {
            List<string[]> l = listAds();
            rbl.DataSource = from obj in l
                             select new
                             {
                                 Id = obj[0],
                                 Name = obj[1]
                             };

            rbl.DataTextField = "Name";
            rbl.DataValueField = "Id";
            rbl.DataBind();
            rbl.SelectedIndex = 0;
        }
Exemple #9
0
        public static void createItemLanguage(ref RadioButtonList rbl)
        {
            List<string[]> l = new List<string[]> { new string[] { "1", "Việt Nam" }, new string[] { "2", "English" } };

            rbl.DataSource = from obj in l
                             select new
                             {
                                 Id = obj[0],
                                 Name = obj[1]
                             };

            rbl.DataTextField = "Name";
            rbl.DataValueField = "Id";
            rbl.DataBind();
            rbl.SelectedIndex = 0;
        }
        private void FillOperRbl(string strDeptID)
        {
            try
            {
                //DataTable dtAllOper = OperFacade.GetAllOperNoAdmin();
                DataTable dtOper = ReportQueryFacade.CommonQuery("select * from tbOper where cnvcOperName <>'admin' and cnvcDeptID like '" + strDeptID + "%' order by cnvcOperName");
                rblOper.DataSource     = dtOper;
                rblOper.DataTextField  = "cnvcOperName";
                rblOper.DataValueField = "cnnOperID";

                rblOper.DataBind();
            }
            catch (BusinessException bex)
            {
                Popup(bex.Message);
            }
        }
        public static void createItemAdPos(ref RadioButtonList rbl)
        {
            List<string[]> l = new List<string[]> 
            { 
                new string[] { "0", "Slideshow" }, 
                new string[] { "1", "Advertising" },
            };

            rbl.DataSource = from obj in l
                             select new
                             {
                                 Id = obj[0],
                                 Name = obj[1]
                             };

            rbl.DataTextField = "Name";
            rbl.DataValueField = "Id";
            rbl.DataBind();
            rbl.SelectedIndex = 0;
        }
		public SingleSelectControl(SingleSelect question, RepeatDirection direction)
		{
			rbl = new RadioButtonList();
			rbl.CssClass = "alternatives";
			rbl.ID = "q" + question.ID;
			rbl.DataTextField = "Title";
			rbl.DataValueField = "ID";
			rbl.DataSource = question.GetChildren();
			rbl.RepeatLayout = RepeatLayout.Flow;
			rbl.RepeatDirection = direction;
			rbl.DataBind();

			l = new Label();
			l.CssClass = "label";
			l.Text = question.Title;
			l.AssociatedControlID = rbl.ID;

			Controls.Add(l);
			Controls.Add(rbl);
		}
        public TreeNavigatorControl(HierarchyNavTable hierarchy, List<UserAction> actions)
        {
            this.hierarchy = hierarchy;
            this.actions = actions;

                tree = new TreeView();

                tree.ShowLines = true;
                WC.TreeNode item;

                foreach (HierarchyRow r in hierarchy.Rows)
                {
                    if (r.ParentId == null)
                    {
                        item = new WC.TreeNode(r.Caption, r.NavId.ToString());
                        AddSubtreeForItem(r, item);
                        tree.Nodes.Add(item);
                    }
                }
                tree.SelectedNodeChanged += SelectionChanged;
                tree.SelectedNodeStyle.Font.Bold = true;

                radios = new RadioButtonList();
                radios.DataSource = actions;
                radios.DataBind();

                // if there is only one action option, don`t show the radios at all
                if (actions.Count == 1)
                {
                    radios.SelectedIndex = 0;
                    radios.Visible = false;
                }
                radios.SelectedIndexChanged += SelectionChanged;
                radios.AutoPostBack = true;

            this.Controls.Add(tree);
            this.Controls.Add(radios);
        }
Exemple #14
0
        private void ddl_search_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            tbx_searchvalue.Text = "";
            tbx_searchvalue.Attributes["onfocus"] = "";
            tbx_searchvalue.ReadOnly = false;
            object[] array;
            switch (ddl_search.SelectedItem.Value)
            {
            case "销售阶段":
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = true;
                array = Enum.GetNames(typeof(UDS.Components.ContactStat));
                for (int i = 0; i < array.Length; i++)
                {
                    switch (array[i].ToString())
                    {
                    case "trace":
                        array[i] = "跟踪";
                        break;

                    case "boot":
                        array[i] = "启动";
                        break;

                    case "commend":
                        array[i] = "产品推荐";
                        break;

                    case "requirement":
                        array[i] = "需求定义";
                        break;

                    case "submit":
                        array[i] = "方案提交";
                        break;

                    case "negotiate":
                        array[i] = "商务谈判";
                        break;

                    case "actualize":
                        array[i] = "项目实施";
                        break;

                    case "traceservice":
                        array[i] = "跟踪服务";
                        break;

                    case "last":
                        array[i] = "收尾款";
                        break;
                    }
                }
                rbl_searchvalue.DataSource = array;
                rbl_searchvalue.DataBind();
                break;

            case "成交预估":
                array = new string[] { "*", "**", "***", "****", "*****", };
                tbx_searchvalue.Visible    = false;
                rbl_searchvalue.Visible    = true;
                rbl_searchvalue.DataSource = array;
                rbl_searchvalue.DataBind();
                break;

            case "首次接洽时间":
                tbx_searchvalue.ReadOnly = true;
                tbx_searchvalue.Attributes["onfocus"] = "setday(this)";
                break;

            case "最后一次接洽时间":
                tbx_searchvalue.Visible  = true;
                rbl_searchvalue.Visible  = false;
                tbx_searchvalue.ReadOnly = true;
                tbx_searchvalue.Attributes["onfocus"] = "setday(this)";
                break;

            case "下次约见时间":
                tbx_searchvalue.Visible  = true;
                rbl_searchvalue.Visible  = false;
                tbx_searchvalue.ReadOnly = true;
                tbx_searchvalue.Attributes["onfocus"] = "setday(this)";
                break;

            case "本周新增记录":
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = false;
                break;

            case "本月新增记录":
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = false;
                break;

            default:
                tbx_searchvalue.Visible = true;
                rbl_searchvalue.Visible = false;
                break;
            }
        }
        private void PopulateSurvey(SurveyResponse response, UtilityBL.Mode mode)
        {
            var survey = response.SurveyTitle;

            if (survey == null)
            {
                lblSurveyTitle.Text = "Invalid Survey";
                return;
            }
            lblSurveyTitle.Text = survey.SurveyTitle1;
            lblSurveyDescription.Text = survey.Description;

            var score = 0;
            var hasAnswers = false;
            if (response.QuestionResponses.Any())
                hasAnswers = true;

            foreach (var section in survey.SurveySections)
            {

                var divSection = new HtmlGenericControl("div");
                divSection.Attributes.Add("id", "divSection" + section.SurveySectionId.ToString());
                divSection.Attributes.Add("class", "panel panel-info");

                if (section.SectionTypeId == (int)UtilityBL.SectionType.Doctor)
                {
                    if (mode != UtilityBL.Mode.Entry)
                        pnlDoctorSection.Controls.Add(divSection);
                    else
                        continue;
                }
                else
                    Panel1.Controls.Add(divSection);

                var divSectionTitle = new HtmlGenericControl("div");
                divSectionTitle.Attributes.Add("id", "divSectionTitle" + section.SurveySectionId.ToString());
                divSectionTitle.Attributes.Add("class", "panel-heading");
                divSection.Controls.Add(divSectionTitle);

                if (section.DisplaySectionHeader && !string.IsNullOrEmpty(section.SurveySectionTtile))
                {
                    var lblSectionTitle = new Label();
                    lblSectionTitle.Text = section.SurveySectionTtile;
                    lblSectionTitle.Font.Bold = true;
                    lblSectionTitle.Font.Size = FontUnit.Large;
                    divSectionTitle.Controls.Add(lblSectionTitle);

                    if (!string.IsNullOrEmpty(section.SurveySectionDesc))
                    {
                        var sectionPara = new HtmlGenericControl("p");
                        sectionPara.Attributes.Add("id", "p" + section.SurveySectionId.ToString());
                        divSectionTitle.Controls.Add(sectionPara);

                        var lblSectionDescription = new Label();
                        lblSectionDescription.Text = section.SurveySectionDesc;
                        lblSectionDescription.Font.Size = FontUnit.Small;
                        sectionPara.Controls.Add(lblSectionDescription);
                    }
                }

                var divSectionBody = new HtmlGenericControl("div");
                divSectionBody.Attributes.Add("id", "divSectionBody" + section.SurveySectionId.ToString());
                divSectionBody.Attributes.Add("class", "panel-body");
                divSection.Controls.Add(divSectionBody);

                foreach (var q in section.Questions)
                {
                    var divQuestion = new HtmlGenericControl("div");
                    divQuestion.Attributes.Add("id", "divQuestion" + q.QuestionId.ToString());
                    divQuestion.Attributes.Add("class", "panel panel-default");
                    divSectionBody.Controls.Add(divQuestion);

                    var divQuestionTitle = new HtmlGenericControl("div");
                    divQuestionTitle.Attributes.Add("id", "divQuestionTitle" + q.QuestionId.ToString());
                    divQuestionTitle.Attributes.Add("class", "panel-heading");
                    divQuestion.Controls.Add(divQuestionTitle);


                    var lblQuestion = new Label();
                    lblQuestion.Text = q.Question1;
                    lblQuestion.ID = "lblQuestion" + q.QuestionId.ToString();
                    lblQuestion.Font.Bold = true;
                    divQuestionTitle.Controls.Add(lblQuestion);

                    var divQuestionBody = new HtmlGenericControl("div");
                    divQuestionBody.Attributes.Add("class", "panel-body");
                    divQuestionBody.Attributes.Add("id", "divQuestionBody" + q.QuestionId.ToString());
                    divQuestion.Controls.Add(divQuestionBody);

                    if (q.QuestionTypeId == 1)
                    {
                        var rdbList = new RadioButtonList();
                        rdbList.ID = "ctrl" + q.QuestionId.ToString();
                        rdbList.DataTextField = "QuestionOption1";
                        rdbList.DataValueField = "QuestionOptionId";
                        rdbList.DataSource = q.QuestionOptions;
                        rdbList.DataBind();
                        rdbList.Attributes.Add("class", "radio radiobuttonlist");

                        if (hasAnswers)
                        {
                            var answr = q.QuestionResponses.FirstOrDefault(r => r.SurveyResponse.SurveyResponseId == response.SurveyResponseId);
                            if (answr != null)
                                rdbList.SelectedValue = answr.QuestionOptionId.ToString();
                        }

                        if (q.DependentonQuestion != null)
                        {
                            var parentAnswer = q.DependentonQuestion.QuestionResponses.FirstOrDefault(r => r.SurveyResponse.SurveyResponseId == response.SurveyResponseId);
                            if (parentAnswer == null || q.EnabledValue != parentAnswer.ResponseText)
                            {
                                foreach (ListItem radio in rdbList.Items)
                                    radio.Enabled = false;
                            }
                        }
                            
                        divQuestionBody.Controls.Add(rdbList);
                    }

                    else if (q.QuestionTypeId == 2)
                    {
                        var chkList = new CheckBoxList();
                        chkList.ID = "ctrl" + q.QuestionId.ToString();
                        chkList.DataTextField = "QuestionOption1";
                        chkList.DataValueField = "QuestionOptionId";
                        chkList.DataSource = q.QuestionOptions;
                        chkList.DataBind();
                        chkList.Attributes.Add("class", "checkbox checked-list-box");

                        if (hasAnswers)
                        {
                            foreach (ListItem item in chkList.Items)
                            {
                                if (q.QuestionResponses.Any(r => r.QuestionOptionId == Convert.ToInt32(item.Value) && r.SurveyResponse.SurveyResponseId == response.SurveyResponseId))
                                {
                                    item.Selected = true;
                                    var qOption = q.QuestionOptions.FirstOrDefault(o => o.QuestionOptionId == Convert.ToInt32(item.Value));
                                }
                            }
                        }

                        if (q.DependentonQuestion != null)
                            chkList.Attributes.Add("disabled", "disabled");

                        divQuestionBody.Controls.Add(chkList);
                    }

                    if (q.QuestionTypeId == 3)
                    {
                        var txt = new TextBox();
                        txt.ID = "ctrl" + q.QuestionId.ToString();
                        txt.Attributes.Add("class", "form-control input-md col-md-10");
                        txt.Attributes.Add("style", "width:80%; max-width:700px;");

                        if (hasAnswers)
                        {
                            var answr = q.QuestionResponses.FirstOrDefault(r => r.SurveyResponse.SurveyResponseId == response.SurveyResponseId);
                            if (answr != null)
                                txt.Text = answr.ResponseText;
                        }

                        if (mode == UtilityBL.Mode.ViewMode || mode == UtilityBL.Mode.ApproveMode)
                            txt.ReadOnly = true;

                        if (q.DependentonQuestion != null)
                            txt.Attributes.Add("disabled", "disabled");

                        divQuestionBody.Controls.Add(txt);
                    }
                }
            }
            if ((mode == UtilityBL.Mode.ViewMode || mode == UtilityBL.Mode.ApproveMode)
                && survey.SurveySections.Any(s => s.Questions.Any(q => q.QuestionOptions.Sum(o => o.Value ?? 0) > 0)))
            {
                score = response.QuestionResponses.Where(x => x.Question.SurveySection.SectionTypeId == (int)UtilityBL.SectionType.Patient)
                                            .Select(s => s.QuestionOption.Value).Sum(r => r.Value);

                var interpretation = _db.InterpretationDetails.FirstOrDefault(d => d.SurveyInterpretation.SurveyTitleId == response.SurveyTitleId
                                                                && d.ScoreRangeStart >= score && score <= d.ScoreRangeEnd);

                if (interpretation != null)
                {
                    pnlSurveyInterpretation.Visible = true;

                    lblScore.Text = score.ToString();
                    lblResult.Text = interpretation.Result;

                    if (!string.IsNullOrEmpty(interpretation.Action))
                        lblAction.Text = interpretation.Action;
                    else
                        lblACtionCaption.Visible = false;
                }
            }

            if (mode == UtilityBL.Mode.ApproveMode)
                DependetQuestionState(response, UtilityBL.SectionType.Doctor);
            else if (mode == UtilityBL.Mode.Entry)
                DependetQuestionState(response, UtilityBL.SectionType.Patient);
        }       
 /// <summary>
 /// 绑定RadioButtonList
 /// </summary>
 /// <param name="strSql"></param>
 /// <param name="fieldName"></param>
 /// <param name="valueNmae"></param>
 /// <param name="rbtName"></param>
 protected void GetFromData(string strSql, string fieldName, string valueNmae, RadioButtonList rbtName)
 {
     Database db = DatabaseFactory.CreateDatabase(CawConnStr);
     DataView dvReturn = db.ExecuteDataView(CommandType.Text, strSql);
     rbtName.DataSource = dvReturn;
     rbtName.DataTextField = fieldName;
     rbtName.DataValueField = valueNmae;
     rbtName.DataBind();
 }
 private void BindRBLWithREF(RadioButtonList rbl)
 {
     rbl.DataSource = SageFrameLists.YESNO();
     rbl.DataTextField = "value";
     rbl.DataValueField = "key";
     rbl.DataBind();
     rbl.RepeatColumns = 2;
     rbl.RepeatDirection = RepeatDirection.Horizontal;
 }
Exemple #18
0
 public void FillToRadioList(RadioButtonList radiolist, DataTable datatable, string displayMember, string valueMember)
 {
     if (datatable != null)
     {
         radiolist.DataSource = datatable;
         radiolist.DataTextField = displayMember;
         radiolist.DataValueField = valueMember;
     }
     else
     {
         radiolist.DataSource = null;
     }
     radiolist.DataBind();
 }
        void cargarBancosRadio(RadioButtonList lista, string empid, string tipo)
        {
            List<Banco> lBancos = tipoPagoFactRN.getBancos(empid, tipo);

                lista.DataSource = lBancos;
                lista.DataTextField = "descripcion";
                lista.DataValueField = "bank_id";
                lista.DataBind();
        }
Exemple #20
0
        public static RadioButtonList FillWygladDropDownList(RadioButtonList DDLWyglad)
        {
            SqlConnection con = new SqlConnection(Usr.ConnectionString);
            con.Open();
            SqlCommand cmd = new SqlCommand("SELECT budowa_ciala_id, budowa_ciala_opis FROM Budowa", con);
            try
            {
                SqlDataReader reader = cmd.ExecuteReader();
                DDLWyglad.DataSource = reader;
                DDLWyglad.DataTextField = "budowa_ciala_opis";
                DDLWyglad.DataValueField = "budowa_ciala_id";
                DDLWyglad.DataBind();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Trace.Write(ex.Message);

            }
            finally
            {
                con.Close();

            }

            return DDLWyglad;
        }
Exemple #21
0
        public void RenderNewTable_WebControl2(Control controlPlaceHolder, DataView DvFields, int TableID)
        {
            string str_ControlID_Prefix = controlPlaceHolder.ClientID.Remove(controlPlaceHolder.ClientID.LastIndexOf('_'));

            HtmlTable tbReport = new HtmlTable();
            tbReport.Width = "100%";
            tbReport.ID = "Table_Add";
            tbReport.CellSpacing = 1;

            Epoint.MisBizLogic2.Code.DB_CodeItem codes = new Epoint.MisBizLogic2.Code.DB_CodeItem();
            Epoint.MisBizLogic2.Code.DB_CodeMain main = new Epoint.MisBizLogic2.Code.DB_CodeMain();
            //DvFields.Sort = "OrderNumInGrid desc";
            HtmlTableRow trNew = new HtmlTableRow();
            HtmlTableCell cell = new HtmlTableCell();

            TextBox txtInCell = new TextBox();
            Epoint.Web.UI.WebControls2X.TextBox txtInCellMulText = new Epoint.Web.UI.WebControls2X.TextBox();
            Button btnInCell = new Button();
            LiteralControl ltcInCell = new LiteralControl();
            System.Web.UI.HtmlControls.HtmlInputFile fileUpload = new HtmlInputFile();

            CompareValidator comp;
            RequiredFieldValidator req;
            RegularExpressionValidator reg;
            Epoint.Web.UI.WebControls2X.TreeViewControls.TextTreeView tvcIncell;
            ListItem item;
            string strFieldName = "";

            int j = 0;
            string strValueUrl = "";

            //Add By XGC 2009-12-1 筛选不需要显示的字段
            DvFields.RowFilter = "DispInAdd=1";
            for (int i = 0; i < DvFields.Count; i++)
            {

                //字段中文名称单元格
                cell = new HtmlTableCell();
                //add by liq 为了实现字段的隐藏,需要标识单元格   2008-10-18
                cell.ID = "FieldDesc_" + DvFields[i]["fieldName"].ToString() + "_" + TableID.ToString();

                if (Convert.ToString(DvFields[i]["IsAllNull"]) == "1")
                    cell.InnerHtml = DvFields[i]["fieldChineseName"].ToString() + "<font color=red>(*)</font>";
                else
                    cell.InnerText = DvFields[i]["fieldChineseName"].ToString();

                cell.Attributes.Add("class", "TableSpecial1");
                cell.Width = "15%";

                trNew.Cells.Add(cell);

                strFieldName = DvFields[i]["fieldName"].ToString();

                //字段控件单元格
                cell = new HtmlTableCell();
                cell.Attributes.Add("Class", "TableSpecial");
                cell.Height = "26";
                cell.Width = "85%";

                //add by liq 为了实现字段的隐藏,需要标识单元格   2008-10-18
                cell.ID = "FieldInput_" + DvFields[i]["fieldName"].ToString() + "_" + TableID.ToString();

                #region 根据字段类型写入控件
                //外键字段不需要填写

                switch (DvFields[i]["fieldDisplayType"].ToString().ToLower())
                {
                    case "textbox":
                        #region TextBox类型
                        //strValueUrl = GetValueUrlProperty(DvFields[i]["ValueUrl"]);
                        txtInCell = new Epoint.Web.UI.WebControls2X.TextBox();// TextBox();
                        txtInCell.ID = strFieldName + "_" + TableID;
                        if (strValueUrl == "")
                        {
                            txtInCell.Width = Unit.Percentage(80);
                        }
                        txtInCell.BackColor = System.Drawing.Color.FromName("white");
                        txtInCell.BorderStyle = BorderStyle.Inset;
                        txtInCell.Font.Size = FontUnit.Point(9);
                        txtInCell.EnableViewState = true;

                        txtInCell.Attributes.Add("datatype", DvFields[i]["fieldType"].ToString());
                        txtInCell.Attributes.Add("maxsize", DvFields[i]["fieldLength"].ToString());
                        txtInCell.Attributes.Add("chname", DvFields[i]["fieldChineseName"].ToString());

                        cell.Controls.Add(txtInCell);

                        if (strValueUrl != "")
                        {
                            cell.Controls.Add(new LiteralControl("<input type=\"button\" value=\"...\" onclick=\"java" + "script:SelectUrl(" + str_ControlID_Prefix + "_" + txtInCell.ID + ",'" + HttpContext.Current.Request.ApplicationPath + "/EpointMis/Pages/BackEnd/iFrame.aspx?PageUrl=" + strValueUrl + "')\">"));
                        }

                        //对于数值型的控件,右对齐

                        if (DvFields[i]["FieldType"].ToString().ToLower() == "numeric"
                            || DvFields[i]["FieldType"].ToString().ToLower() == "money"
                            || DvFields[i]["FieldType"].ToString().ToLower() == "int")
                        {
                            txtInCell.Style.Add("TEXT-ALIGN", "right");
                            txtInCell.Style.Add("padding-right", "2px");
                        }

                        #region 添加数字验证控件

                        string strDataType1 = DvFields[i]["fieldType"].ToString();
                        if (strDataType1.ToLower().IndexOf("int") > -1) //整数字段
                        {
                            comp = new CompareValidator();
                            comp.ID = "comp_" + strFieldName + "_" + TableID;
                            comp.ControlToValidate = txtInCell.ID;
                            comp.Operator = ValidationCompareOperator.DataTypeCheck;
                            comp.Type = ValidationDataType.Integer;
                            comp.EnableClientScript = true;
                            comp.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + ":必须填写整数类型数据!";
                            comp.Display = ValidatorDisplay.None;
                            comp.ForeColor = System.Drawing.Color.Red;
                            comp.Visible = true;
                            cell.Controls.Add(comp);
                        }

                        if (strDataType1.ToLower().IndexOf("numeric") > -1) //浮点数字段
                        {
                            comp = new CompareValidator();
                            comp.ID = "comp_" + strFieldName + "_" + TableID;
                            comp.ControlToValidate = txtInCell.ID;
                            comp.Operator = ValidationCompareOperator.DataTypeCheck;
                            comp.Type = ValidationDataType.Double;
                            comp.EnableClientScript = true;
                            comp.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + ":不是合法的数字!";
                            comp.Display = ValidatorDisplay.None;
                            comp.ForeColor = System.Drawing.Color.Red;
                            comp.Visible = true;
                            cell.Controls.Add(comp);
                        }

                        if (strDataType1.ToLower().IndexOf("datetime") > -1) //浮点数字段
                        {
                            comp = new CompareValidator();
                            comp.ID = "comp_" + strFieldName + "_" + TableID;
                            comp.ControlToValidate = txtInCell.ID;
                            comp.Operator = ValidationCompareOperator.DataTypeCheck;
                            comp.Type = ValidationDataType.Date;
                            comp.EnableClientScript = true;
                            comp.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + ":不是合法的日期!";
                            comp.Display = ValidatorDisplay.None;
                            comp.ForeColor = System.Drawing.Color.Red;
                            comp.Visible = true;
                            cell.Controls.Add(comp);
                        }
                        #endregion

                        #region 必填校验和正则表达式校验

                        if (Convert.ToString(DvFields[i]["IsAllNull"]) == "1")
                        {
                            req = new RequiredFieldValidator();
                            req.ID = "req_" + strFieldName + "_" + TableID;
                            req.ControlToValidate = txtInCell.ID;
                            req.Display = ValidatorDisplay.None;
                            req.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + "必填";
                            cell.Controls.Add(req);
                        }

                        if (Convert.ToString(DvFields[i]["validCheckFormula"]) != "")
                        {
                            reg = new RegularExpressionValidator();
                            reg.ID = "reg_" + strFieldName + "_" + TableID;
                            reg.ValidationExpression = Convert.ToString(DvFields[i]["validCheckFormula"]);
                            reg.ControlToValidate = txtInCell.ID;
                            reg.Display = ValidatorDisplay.None;
                            reg.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + ":不符合格式要求";
                            cell.Controls.Add(reg);
                        }
                        #endregion
                        break;
                        #endregion
                    case "datetimepick":
                    case "datepick"://add by liq 2008-6-30
                        #region 日期类型
                        Epoint.Web.UI.WebControls2X.DateTextBox dtb = new Epoint.Web.UI.WebControls2X.DateTextBox();
                        dtb.ID = strFieldName + "_" + TableID;
                        dtb.Character = Epoint.Web.UI.WebControls2X.DateCharacter.HX;
                        if (Convert.ToString(DvFields[i]["IsAllNull"]) == "1")
                        {
                            dtb.AllowNull = false;
                            dtb.RelationName = DvFields[i]["fieldChineseName"].ToString();
                        }
                        if (DvFields[i]["fieldDisplayType"].ToString().ToLower() == "datetimepick")
                        {
                            dtb.DateControlType = Epoint.Web.UI.WebControls2X.eDateTextBox.DateTime;
                        }
                        else
                        {
                            dtb.DateControlType = Epoint.Web.UI.WebControls2X.eDateTextBox.Date;
                        }
                        dtb.InputDateType = Epoint.Web.UI.WebControls2X.eInputDateType.Select;

                        cell.Controls.Add(dtb);
                        break;
                        #endregion
                    case "html":

                        break;
                    case "dropdownlist":
                        #region 下拉框类型
                        DropDownList jpdIncell = new DropDownList();
                        jpdIncell.ID = strFieldName + "_" + TableID;
                        jpdIncell.Width = Unit.Percentage(80);
                        jpdIncell.Height = Unit.Percentage(100);
                        jpdIncell.BackColor = System.Drawing.Color.FromName("white");
                        jpdIncell.BorderStyle = BorderStyle.Inset;
                        jpdIncell.Font.Size = FontUnit.Point(9);
                        jpdIncell.EnableViewState = true;

                        //jpdIncell.DataSource = codes.Get_Items_By_CodeName(DvFields[i]["DataSource_CodeName"].ToString());
                        //jpdIncell.DataTextField = "ItemText";
                        //jpdIncell.DataValueField = "ItemValue";
                        //jpdIncell.DataBind();

                        //if (DvFields[i]["fieldDefaultValue"].ToString() != "")
                        //    jpdIncell.SelectedValue = OtherFunction.getFieldDefaultValue(DvFields[i]["fieldDefaultValue"].ToString());
                        cell.Controls.Add(jpdIncell);
                        if (Convert.ToString(DvFields[i]["IsAllNull"]) == "1")
                        {
                            System.Web.UI.WebControls.RequiredFieldValidator RFV = new RequiredFieldValidator();
                            RFV.ID = "RFV" + strFieldName;
                            RFV.ControlToValidate = jpdIncell.ID;
                            RFV.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + "必填";
                            cell.Controls.Add(RFV);
                        }
                        break;
                        #endregion
                    case "textarea":
                        #region 多行文本框
                        //strValueUrl = GetValueUrlProperty(DvFields[i]["ValueUrl"]);
                        txtInCellMulText = new Epoint.Web.UI.WebControls2X.TextBox();
                        txtInCellMulText.ID = strFieldName + "_" + TableID;
                        txtInCellMulText.Width = Unit.Percentage(97);
                        txtInCellMulText.Height = Unit.Pixel(100);
                        txtInCellMulText.TextMode = TextBoxMode.MultiLine;
                        if (strValueUrl == "")
                        {
                            txtInCellMulText.Width = Unit.Percentage(100);
                        }
                        txtInCellMulText.BackColor = System.Drawing.Color.FromName("white");
                        txtInCellMulText.BorderStyle = BorderStyle.Inset;
                        txtInCellMulText.Font.Size = FontUnit.Point(9);
                        txtInCellMulText.EnableViewState = true;

                        //txtInCellMulText.Text = OtherFunction.getDefaultText(DvFields[i]["DefaultValue"]);
                        if (txtInCellMulText.Text == "")
                        {
                            //这是默认值
                            //txtInCellMulText.Text = OtherFunction.getFieldDefaultValue(DvFields[i]["fieldDefaultValue"]);
                        }
                        cell.Controls.Add(txtInCellMulText);
                        if (strValueUrl != "")
                        {
                            cell.Controls.Add(new LiteralControl("<input type=\"button\" value=\"...\" onclick=\"java" + "script:SelectUrl(" + txtInCell.ID + ",'" + HttpContext.Current.Request.ApplicationPath + "/EpointMis/BackEnd/iFrame.aspx?PageUrl=" + strValueUrl + "')\">"));
                        }
                        if (Convert.ToString(DvFields[i]["IsAllNull"]) == "1")
                        {
                            req = new RequiredFieldValidator();
                            req.ID = "req_" + strFieldName + "_" + TableID;
                            req.ControlToValidate = txtInCellMulText.ID;
                            req.Display = ValidatorDisplay.None;
                            req.ErrorMessage = DvFields[i]["fieldChineseName"].ToString() + "必填";
                            cell.Controls.Add(req);
                        }
                        break;
                        #endregion
                    case "radio":
                        #region 单选框
                        RadioButtonList rdoInCell = new RadioButtonList();
                        rdoInCell.RepeatDirection = RepeatDirection.Horizontal;
                        rdoInCell.ID = strFieldName + "_" + TableID;
                        rdoInCell.DataSource = codes.Get_Items_By_CodeName(DvFields[i]["DataSource_CodeName"].ToString());
                        rdoInCell.DataTextField = "ItemText";
                        rdoInCell.DataValueField = "ItemValue";
                        rdoInCell.DataBind();

                        if (rdoInCell.Items.Count > 0)
                        {
                            rdoInCell.SelectedIndex = 0;
                            //if (DvFields[i]["fieldDefaultValue"].ToString() != "")
                            //{
                            //    item = rdoInCell.Items.FindByValue(OtherFunction.getFieldDefaultValue(DvFields[i]["fieldDefaultValue"].ToString()));
                            //    if (item != null)
                            //    {
                            //        rdoInCell.SelectedIndex = rdoInCell.Items.IndexOf(item);
                            //    }
                            //}
                        }

                        cell.Controls.Add(rdoInCell);

                        break;
                        #endregion
                    case "checkbox":
                        #region 多选框
                        CheckBoxList chkInCell = new CheckBoxList();
                        chkInCell.RepeatDirection = RepeatDirection.Horizontal;
                        chkInCell.ID = strFieldName + "_" + TableID;
                        chkInCell.DataSource = codes.Get_Items_By_CodeName(DvFields[i]["DataSource_CodeName"].ToString());
                        chkInCell.DataTextField = "ItemText";
                        chkInCell.DataValueField = "ItemValue";
                        chkInCell.DataBind();

                        cell.Controls.Add(chkInCell);
                        break;
                        #endregion
                    case "calculate":
                        #region 计算
                        txtInCell = new TextBox();
                        txtInCell.ID = strFieldName + "_" + TableID;
                        txtInCell.Width = Unit.Percentage(97);
                        txtInCell.Height = Unit.Percentage(100);
                        txtInCell.BackColor = System.Drawing.Color.FromName("white");
                        txtInCell.BorderStyle = BorderStyle.Inset;
                        txtInCell.Font.Size = FontUnit.Point(9);
                        txtInCell.EnableViewState = true;
                        txtInCell.Enabled = false;
                        txtInCell.ToolTip = "本输入框是计算格,不需用户输入!";
                        txtInCell.BackColor = System.Drawing.ColorTranslator.FromHtml("#FAEBD7");

                        if (DvFields[i]["FieldType"].ToString().ToLower() == "numeric"
                            || DvFields[i]["FieldType"].ToString().ToLower() == "money"
                            || DvFields[i]["FieldType"].ToString().ToLower() == "int")
                        {
                            txtInCell.Style.Add("TEXT-ALIGN", "right");
                            txtInCell.Style.Add("padding-right", "2px");
                        }

                        cell.Controls.Add(txtInCell);
                        break;
                        #endregion
                    case "image":
                        fileUpload = new HtmlInputFile();
                        fileUpload.ID = strFieldName + "_" + TableID;
                        cell.Controls.Add(fileUpload);
                        break;
                    case "texttreeview"://添加一种类型TextTreeView,使用树选择方式来显示。
                        #region 树选择方式

                        #endregion
                        break;
                    case "multitexttreeview":
                        #region 树选择方式

                        #endregion
                        break;
                    case "checkboxlst":
                        #region MyRegion

                        break;
                        #endregion
                    case "radiolst":
                        #region MyRegion

                        break;
                        #endregion

                }
                #endregion

                int nNextControlWidth = (i < DvFields.Count - 1) ? Convert.ToInt32(DvFields[i + 1]["ControlWidth"]) : 1;

                cell.Width = "85%";
                if (DvFields[i]["fieldDisplayType"].ToString().ToLower() == "dropdownlist")
                {

                }

                trNew.Cells.Add(cell);

                tbReport.Rows.Add(trNew);
                trNew = new HtmlTableRow();

            }//循环结尾
            if (trNew.Controls.Count != 0)
            {
                tbReport.Rows.Add(trNew);
            }
            controlPlaceHolder.Controls.Add(tbReport);
        }
        public void TestCreate()
        {
            UserDetailPanel page = new UserDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/UserDetailPanel/DynamicPage.svc?Domain=Department");

                #region bind web control
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                OrganizationSelector OrganizationSelector = new OrganizationSelector();
                //IList<OrganizationObject> ds = new List<OrganizationObject>();
                OrganizationObject organization = new OrganizationObject()
                {
                    OrganizationCode = "123456" + surfix,
                    OrganizationName = "org" + surfix,
                    Status = OrganizationStatus.Enabled,
                    OrganizationTypeId = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId).FirstOrDefault(),
                    Description = "organ"
                };

                organizationApi.Save(organization);
                //ds.Add(organization);
                createdOrganizationIds.Add(organization.OrganizationId);

                OrganizationSelector.SelectedOrganization = organization;

                proxy.Set("OrganizationSelector", OrganizationSelector);

                TextBox TextBoxUserName = new TextBox();
                TextBoxUserName.Text = "Eunge" + surfix;
                proxy.Set("TextBoxUserName", TextBoxUserName);

                TextBox TextBoxPassword = new TextBox();
                TextBoxPassword.Text = "Password" + surfix;
                proxy.Set("TextBoxPassword", TextBoxPassword);

                TextBox TextBoxConfirmPassword = new TextBox();
                TextBoxConfirmPassword.Text = "Password" + surfix;
                proxy.Set("TextBoxConfirmPassword", TextBoxConfirmPassword);

                TextBox TextBoxDisplayName = new TextBox();
                TextBoxDisplayName.Text = "Eunge" + surfix;
                proxy.Set("TextBoxDisplayName", TextBoxConfirmPassword);

                TextBox TextBoxEmail = new TextBox();
                TextBoxEmail.Text = "*****@*****.**";
                proxy.Set("TextBoxEmail", TextBoxEmail);

                TextBox TextBoxMobile = new TextBox();
                TextBoxMobile.Text = "13456789009";
                proxy.Set("TextBoxMobile", TextBoxMobile);

                ExtensionDataForm UserExtensionDataForm = null;
                proxy.Set("UserExtensionDataForm", UserExtensionDataForm);

                TextBox TextBoxComment = new TextBox();
                TextBoxComment.Text = "13456789009" + surfix;
                proxy.Set("TextBoxComment", TextBoxComment);

                Array statusData = new string[] { "true", "false" };
                RadioButtonList RadioButtonListStatus = new RadioButtonList();
                RadioButtonListStatus.DataSource = statusData;
                RadioButtonListStatus.DataBind();
                RadioButtonListStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListStatus", RadioButtonListStatus);

                TextBox TextBoxCreationDate = new TextBox();
                TextBoxCreationDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxCreationDate", TextBoxCreationDate);

                TextBox TextBoxLastLoginDate = new TextBox();
                TextBoxLastLoginDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastLoginDate", TextBoxLastLoginDate);

                TextBox TextBoxLastActivityDate = new TextBox();
                TextBoxLastActivityDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastActivityDate", TextBoxLastActivityDate);

                TextBox TextBoxLockedOutDate = new TextBox();
                TextBoxLockedOutDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLockedOutDate", TextBoxLockedOutDate);

                TextBox TextBoxLastPasswordChangedDate = new TextBox();
                TextBoxLastPasswordChangedDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastPasswordChangedDate", TextBoxLastPasswordChangedDate);

                TextBox TextBoxLastUpdatedDate = new TextBox();
                TextBoxLastUpdatedDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastUpdatedDate", TextBoxLastUpdatedDate);

                PermissionTreeView @PermissionTreeView = null;
                proxy.Set("PermissionTreeView", @PermissionTreeView);

                #endregion
                string entity = proxy.Create();
                createdObjectIds.Add(new Guid(entity));

            }
        }
Exemple #23
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "main.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                // getting the Bread Crumbs from Cookie and add last item
                if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                {
                    Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                }
                Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Main");

                SaveCancelControl.ParentPageURL = this.ParentPageURL;

                if (!IsPostBack)
                {
                    order         = new clsWorkOrders();
                    user          = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId  = OrgId;
                    order.iId     = OrderId;
                    user.iOrgId   = OrgId;
                    user.iTypeId  = (int)UserTypes.Technician;

                    rblWOTypes.DataSource = order.GetTypesList();
                    rblWOTypes.DataBind();

                    ddlTech.DataSource = new DataView(user.GetUserListByType());
                    ddlTech.DataBind();

                    if (order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();
                        Session["error"]    = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    status   = (WorkOrderStatus)order.iStatusId.Value;
                    opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value;

                    ViewState["StatusId"] = status;

                    lblWorkOrderId.Text       = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    rblWOTypes.SelectedValue  = order.iTypeId.Value.ToString();
                    hlEquipId.Text            = order.sEquipId.Value;
                    hlEquipId.NavigateUrl     = "e_view.aspx?id=" + order.iEquipId.Value.ToString();
                    hlSpareEquipId.Text       = order.sSpareEquipId.Value;
                    hlChangeSpare.NavigateUrl = "wo_selectSpareEquip.aspx?id=" + OrderId.ToString() + "&back=edit";
                    if (order.iSpareEquipId.Value > 0)
                    {
                        hlSpareEquipId.NavigateUrl = "e_view.aspx?id=" + order.iSpareEquipId.Value.ToString();
                    }
                    if (order.iTechId.Value != 0)
                    {
                        ddlTech.Items.Remove(ddlTech.Items[0]);
                        if (ddlTech.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                        {
                            ddlTech.SelectedValue = order.iTechId.Value.ToString();
                        }
                        else
                        {
                            Header.ErrorMessage = "Cannot find the assigned technician in the technician list";
                        }
                    }
                    lblOperator.Text = order.sOperatorName.Value;

                    if (order.bStaying.Value)
                    {
                        rblStaying.SelectedValue = "True";
                    }
                    else
                    {
                        rblStaying.SelectedValue = "False";
                    }
                    tbDroppedOffBy.Text = order.sDropedOffBy.Value;
                    tbReleasedTo.Text   = order.sReleasedTo.Value;
                    tbCleanliness.Text  = order.sCleanliness.Value;
                    adtScheduled.Date   = order.daScheduled.Value;
                    lblCreatedDate.Text = order.daCreated.Value.ToLongDateString();
                    switch (status)
                    {
                    case WorkOrderStatus.Scheduled:                             // Scheduled status
                        hlChangeSpare.Enabled        = false;
                        ddlTech.Enabled              = false;
                        rblStaying.Enabled           = false;
                        tbDroppedOffBy.Enabled       = false;
                        tbCleanliness.Enabled        = false;
                        tbReleasedTo.Enabled         = false;
                        adtScheduled.Enabled         = true;
                        html_ScheduledDate.Visible   = true;
                        SaveCancelControl.EnableSave = true;
                        if (opstatus == WorkOrderOperatorStatus.Checked_In)
                        {
                            hlChangeSpare.Enabled = true;
                            trCheckInDate.Visible = true;
                            adtCheckIn.Date       = order.daArrival.Value;
                        }
                        else
                        {
                            trCheckInDate.Visible = false;
                        }
                        trCheckOutDate.Visible = false;
                        trClosedDate.Visible   = false;
                        trOpenedDate.Visible   = false;
                        break;

                    case WorkOrderStatus.Open:                             // Opened status
                        ViewState["ScheduledDate"]   = order.daScheduled.Value;
                        adtScheduled.Enabled         = false;
                        html_ScheduledDate.Visible   = false;
                        SaveCancelControl.EnableSave = true;
                        trCheckInDate.Visible        = true;
                        adtCheckIn.Date        = order.daArrival.Value;
                        trOpenedDate.Visible   = true;
                        adtOpened.Date         = order.daOpened.Value;
                        trCheckOutDate.Visible = false;
                        trClosedDate.Visible   = false;
                        break;

                    case WorkOrderStatus.ReOpened:                             // Opened status
                        ViewState["ScheduledDate"]   = order.daScheduled.Value;
                        adtScheduled.Enabled         = false;
                        html_ScheduledDate.Visible   = false;
                        SaveCancelControl.EnableSave = true;
                        trCheckInDate.Visible        = true;
                        adtCheckIn.Date        = order.daArrival.Value;
                        trOpenedDate.Visible   = true;
                        adtOpened.Date         = order.daOpened.Value;
                        trCheckOutDate.Visible = false;
                        trClosedDate.Visible   = false;
                        break;

                    case WorkOrderStatus.Closed:                             // Closed Status
                        ViewState["ScheduledDate"]   = order.daScheduled.Value;
                        hlChangeSpare.Enabled        = false;
                        ddlTech.Enabled              = false;
                        rblStaying.Enabled           = false;
                        tbDroppedOffBy.Enabled       = true;
                        adtScheduled.Enabled         = false;
                        html_ScheduledDate.Visible   = false;
                        tbCleanliness.Enabled        = true;
                        tbReleasedTo.Enabled         = true;
                        SaveCancelControl.EnableSave = true;
                        trCheckInDate.Visible        = true;
                        adtCheckIn.Date              = order.daArrival.Value;
                        trOpenedDate.Visible         = true;
                        adtOpened.Date       = order.daOpened.Value;
                        trClosedDate.Visible = true;
                        adtClosed.Date       = order.daClosed.Value;
                        if (opstatus == WorkOrderOperatorStatus.Checked_Out)
                        {
                            trCheckOutDate.Visible = true;
                            adtCheckOut.Date       = order.daDeparture.Value;
                        }
                        else
                        {
                            trCheckOutDate.Visible = false;
                        }
                        break;
                    }
                    if (order.iOperatorId.Value == 6)
                    {
                        hlChangeSpare.Enabled = false;
                    }

                    ShowCustomFields();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = this.ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (user != null)
                {
                    user.Dispose();
                }
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }
        private void GenrateForm()
        {
            try
            {
                if (pnlForm.Controls.Count == 1)
                {
                    var LINQProfile = db.sp_ProfileListActive(GetPortalID);
                    CommonFunction LToDCon = new CommonFunction();
                    DataTable dt = LToDCon.LINQToDataTable(LINQProfile);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        Table tblSageForm = new Table();
                        tblSageForm.CssClass = "cssClassForm";
                        tblSageForm.ID = "tblSageForm";
                        tblSageForm.EnableViewState = true;
                        string parentKey = string.Empty;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            int ProfileID = Int32.Parse(dt.Rows[i]["ProfileID"].ToString());
                            TableRow tbrSageRow = new TableRow();
                            tbrSageRow.ID = "tbrSageRow_" + ProfileID;
                            tbrSageRow.EnableViewState = true;

                            TableCell tcleftSagetd = new TableCell();
                            tcleftSagetd.ID = "tcleftSagetd_" + ProfileID;
                            tcleftSagetd.CssClass = "cssClassFormtdLleft";
                            tcleftSagetd.EnableViewState = true;
                            tcleftSagetd.Width = Unit.Percentage(20);

                            Label lblValue = new Label();
                            lblValue.ID = "lblValue_" + ProfileID;
                            lblValue.Text = dt.Rows[i]["Name"].ToString();
                            lblValue.ToolTip = dt.Rows[i]["Name"].ToString();
                            lblValue.EnableViewState = true;
                            lblValue.CssClass = "cssClassFormLabel";

                            tcleftSagetd.Controls.Add(lblValue);

                            tbrSageRow.Cells.Add(tcleftSagetd);

                            
                            int PropertyTypeID = Int32.Parse(dt.Rows[i]["PropertyTypeID"].ToString());

                            TableCell tcrightSagetd = new TableCell();
                            tcrightSagetd.ID = "tcrightSagetd_" + ProfileID;
                            tcrightSagetd.CssClass = "cssClassFormtdRight";
                            tcrightSagetd.EnableViewState = true;

                            
                            

                            switch (PropertyTypeID)
                            {
                                case 1://TextBox
                                    TextBox BDTextBox = new TextBox();
                                    BDTextBox.ID = "BDTextBox_" + ProfileID;
                                    BDTextBox.CssClass = "cssClassNormalTextBox";
                                    BDTextBox.EnableViewState = true;



                                    int DataType = Int32.Parse(dt.Rows[i]["DataType"].ToString());
                                    switch (DataType)
                                    {
                                        case 0://String
                                            //Adding in Pandel
                                            tcrightSagetd.Controls.Add(BDTextBox);
                                            break;
                                        case 1://Integer
                                            BDTextBox.Attributes.Add("OnKeydown", "return NumberKey(event)");
                                            //Adding in Pandel
                                            tcrightSagetd.Controls.Add(BDTextBox);
                                            break;
                                        case 2://Decimal
                                            BDTextBox.Attributes.Add("OnKeydown", "return NumberKeyWithDecimal(event)");
                                            //Adding in Pandel
                                            tcrightSagetd.Controls.Add(BDTextBox);
                                            break;
                                        case 3://DateTime
                                            ImageButton imb = new ImageButton();
                                            imb.ID = "imb_" + ProfileID;
                                            imb.ImageUrl = GetTemplateImageUrl("imgcalendar.png", true);

                                            CalendarExtender Cex = new CalendarExtender();
                                            Cex.ID = "Cex_" + ProfileID;
                                            Cex.TargetControlID = BDTextBox.ID;
                                            Cex.PopupButtonID = imb.ID;
                                            Cex.SelectedDate = DateTime.Now;
                                            BDTextBox.ToolTip = "DateTime";
                                            BDTextBox.Enabled = false;

                                            //Adding in Panel
                                            tcrightSagetd.Controls.Add(BDTextBox);
                                            tcrightSagetd.Controls.Add(imb);
                                            tcrightSagetd.Controls.Add(Cex);
                                            break;

                                    }

                                    

                                    bool IsRequred = bool.Parse(dt.Rows[i]["IsRequired"].ToString());
                                    if (IsRequred)
                                    {
                                        RequiredFieldValidator rfv = new RequiredFieldValidator();
                                        rfv.ID = "rfv_" + ProfileID;
                                        rfv.ControlToValidate = BDTextBox.ID;
                                        rfv.ErrorMessage = "*";
                                        rfv.ValidationGroup = "UserProfile";
                                        tcrightSagetd.Controls.Add(rfv);
                                    }
                                    

                                    break;
                                case 2://DropDownList
                                    DropDownList ddl = new DropDownList();
                                    ddl.ID = "BDTextBox_" + ProfileID;
                                    ddl.CssClass = "cssClassDropDown";
                                    //ddl.Width = 200;
                                    ddl.EnableViewState = true;

                                    //Setting Data Source
                                    var LinqProvileValue = db.sp_ProfileValueGetActiveByProfileID(ProfileID, GetPortalID);
                                    ddl.DataSource = LinqProvileValue;
                                    ddl.DataValueField = "ProfileValueID";
                                    ddl.DataTextField = "Name";
                                    ddl.DataBind();
                                    if (ddl.Items.Count > 0)
                                    {
                                        ddl.SelectedIndex = 0;
                                    }

                                    //Adding in Pandel
                                    tcrightSagetd.Controls.Add(ddl);
                                    break;
                                case 3://CheckBoxList
                                    CheckBoxList chbl = new CheckBoxList();
                                    chbl.ID = "BDTextBox_" + ProfileID;
                                    chbl.CssClass = "cssClassCheckBox";
                                    chbl.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
                                    chbl.RepeatColumns = 2;
                                    chbl.EnableViewState = true;

                                    //Setting Data Source
                                    LinqProvileValue = db.sp_ProfileValueGetActiveByProfileID(ProfileID, GetPortalID);
                                    chbl.DataSource = LinqProvileValue;
                                    chbl.DataValueField = "ProfileValueID";
                                    chbl.DataTextField = "Name";
                                    chbl.DataBind();
                                    if (chbl.Items.Count > 0)
                                    {
                                        chbl.SelectedIndex = 0;
                                    }

                                    //Adding in Pandel
                                    tcrightSagetd.Controls.Add(chbl);
                                    break;
                                case 4://RadioButtonList
                                    RadioButtonList rdbl = new RadioButtonList();
                                    rdbl.ID = "BDTextBox_" + ProfileID;
                                    rdbl.CssClass = "cssClassRadioButtonList";
                                    rdbl.EnableViewState = true;
                                    rdbl.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
                                    rdbl.RepeatColumns = 2;

                                    //Setting Data Source
                                    LinqProvileValue = db.sp_ProfileValueGetActiveByProfileID(ProfileID, GetPortalID);
                                    rdbl.DataSource = LinqProvileValue;
                                    rdbl.DataValueField = "ProfileValueID";
                                    rdbl.DataTextField = "Name";
                                    rdbl.DataBind();
                                    if (rdbl.Items.Count > 0)
                                    {
                                        rdbl.SelectedIndex = 0;
                                    }
									tcrightSagetd.CssClass = "cssClassButtonListWrapper";
                                    //Adding in Pandel
                                    tcrightSagetd.Controls.Add(rdbl);
                                    break;
                                case 5://DropDownList
                                    DropDownList cddl = new DropDownList();
                                    cddl.ID = "BDTextBox_" + ProfileID;
                                    cddl.CssClass = "cssClassDropDown";
                                    //cddl.Width = 200;
                                    cddl.EnableViewState = true;
                                    cddl.SelectedIndexChanged +=new EventHandler(cddl_SelectedIndexChanged);
                                    cddl.AutoPostBack = true;
                                    ViewState["cddlID"] = cddl.ID;
                                    //Setting Data Source
                                    ListManagementDataContext cdb = new ListManagementDataContext(SystemSetting.SageFrameConnectionString);
                                    var CLINQ = cdb.sp_GetListEntrybyNameAndID("Country", -1,GetCurrentCultureName);                                   
                                    cddl.DataSource = CLINQ;
                                    cddl.DataValueField = "Value";
                                    cddl.DataTextField = "Text";
                                    cddl.DataBind();
                                    if (cddl.Items.Count > 0)
                                    {
                                        cddl.SelectedIndex = 0;
                                        parentKey = "Country." + cddl.SelectedItem.Value;
                                    }

                                    //Adding in Pandel
                                    tcrightSagetd.Controls.Add(cddl);
                                    break;
                                case 6://DropDownList
                                    DropDownList Sddl = new DropDownList();
                                    Sddl.ID = "BDTextBox_" + ProfileID;
                                    Sddl.CssClass = "cssClassNormalTextBox";
                                    //Sddl.Width = 200;
                                    Sddl.EnableViewState = true;
                                    ViewState["SddlID"] = Sddl.ID;
                                    //Setting Data Source
                                    string listName = "Region";
                                    ListManagementDataContext Sdb = new ListManagementDataContext(SystemSetting.SageFrameConnectionString);
                                    var listDetail = Sdb.sp_GetListEntriesByNameParentKeyAndPortalID(listName, parentKey, -1,GetCurrentCultureName);
                                    Sddl.DataSource = listDetail;
                                    Sddl.DataValueField = "Value";
                                    Sddl.DataTextField = "Text";
                                    Sddl.DataBind();
                                    if (Sddl.Items.Count > 0)
                                    {
                                        Sddl.SelectedIndex = 0;
                                    }
                                    ViewState["StateRow"] = tbrSageRow.ID;

                                    //Adding in Pandel
                                    tcrightSagetd.Controls.Add(Sddl);
                                    break;
                                case 7://DropDownList
                                    DropDownList TimeZoneddl = new DropDownList();
                                    TimeZoneddl.ID = "BDTextBox_" + ProfileID;
                                    TimeZoneddl.CssClass = "cssClassDropDown";
                                    //TimeZoneddl.Width = 200;
                                    TimeZoneddl.EnableViewState = true;

                                    //Setting Data Source
                                    NameValueCollection nvlTimeZone = SageFrame.Localization.Localization.GetTimeZones(((PageBase)this.Page).GetCurrentCultureName);
                                    TimeZoneddl.DataSource = nvlTimeZone;                                    
                                    TimeZoneddl.DataBind();
                                    if (TimeZoneddl.Items.Count > 0)
                                    {
                                        TimeZoneddl.SelectedIndex = 0;                                       
                                    }

                                    //Adding in Pandel
                                    tcrightSagetd.Controls.Add(TimeZoneddl);
                                    break;
                                case 8://File Upload
                                    FileUpload AsyFlu = new FileUpload();
                                    AsyFlu.ID = "BDTextBox_" + ProfileID;
                                    AsyFlu.CssClass = "cssClassNormalFileUpload";                                    
                                    AsyFlu.EnableViewState = true;
                                    tcrightSagetd.Controls.Add(AsyFlu);

                                    System.Web.UI.HtmlControls.HtmlGenericControl gcDiv = new HtmlGenericControl("div");
                                    gcDiv.ID = "BDDiv_" + ProfileID;
                                    gcDiv.Attributes.Add("class","cssClassProfileImageWrapper");
                                    gcDiv.EnableViewState = true;
                                    gcDiv.Visible = false;

                                    Image img = new Image();
                                    img.ID = "Bdimg_" + ProfileID;
                                    img.CssClass = "cssClassProfileImage";
                                    img.EnableViewState = true;
                                    gcDiv.Controls.Add(img);
                                    tcrightSagetd.Controls.Add(gcDiv);
                                    break;
                            }
                            tbrSageRow.Cells.Add(tcrightSagetd);
                            tblSageForm.Rows.Add(tbrSageRow);
                            pnlForm.Controls.Add(tblSageForm);
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
 protected void RadioListBind(RadioButtonList List, string DataTypeValue)
 {
     DataTable dt = new DataTable();
     dt = bllTypeData.GetTypeDataList(DataTypeValue);
     List.DataSource = dt;
     List.DataTextField = "DataValue";
     List.DataValueField = "DataCode";
     List.DataBind();
 }
Exemple #26
0
        public static void RblFill(ref RadioButtonList rbl, object list, bool appendFirstItem = false, ListFirstItemType firstItemType = ListFirstItemType.SelectAll)
        {
            rbl.Items.Clear();
            bool appDatBouItems = rbl.AppendDataBoundItems;//Запоминаем текущее значение, чтобы потом восстановить

            if (appendFirstItem)
            {
                rbl.AppendDataBoundItems = true;
                ListItem li = new ListItem();

                switch (firstItemType)
                {
                    case ListFirstItemType.SelectAll:
                        li.Text = rblSelectAllText;
                        li.Value = rblSelectAllValue;
                        break;
                }

                rbl.Items.Add(li);
            }

            rbl.DataTextField = listDefaultDataTextField;
            rbl.DataValueField = listDefaultDataValueField;
            rbl.DataSource = list;
            rbl.DataBind();

            if (appendFirstItem)
            {
                rbl.AppendDataBoundItems = appDatBouItems;//Восстанавливаем запомненное значение
            }
        }
Exemple #27
0
		public void AppendEditViewFieldsEdit(string sEDIT_NAME, HtmlTable tbl, DataRowView rdr, ref int nRowIndex, string sFIELD_WIDTH, Hashtable hashIncludedFields, bool bIsPostBack)
		{
			DataTable dtFields = SplendidCache.EditViewFields(sEDIT_NAME);
			DataView dvFields = dtFields.DefaultView;

			string sIDSuffix = String.Empty;
			//if ( nRecordIndex > 0 )
			//	sIDSuffix = nRecordIndex.ToString("_##");

			int nColIndex = 0;
			HtmlTableRow  tr      = null;
			HtmlTableCell tdLabel = null;
			HtmlTableCell tdField = null;
			if ( dvFields.Count == 0 && tbl.Rows.Count <= 1 )
				tbl.Visible = false;

			// 01/18/2010   To apply ACL Field Security, we need to know if the current record has an ASSIGNED_USER_ID field, and its value. 
			Guid gASSIGNED_USER_ID = Guid.Empty;
			DataColumnCollection vwSchema = null;
			if ( rdr != null )
			{
				vwSchema = rdr.DataView.Table.Columns;
				if ( vwSchema.Contains("ASSIGNED_USER_ID") )
				{
					gASSIGNED_USER_ID = Sql.ToGuid(rdr["ASSIGNED_USER_ID"]);
				}
			}

			bool bEnableTeamManagement  = Crm.Config.enable_team_management();
			bool bRequireTeamManagement = Crm.Config.require_team_management();
			bool bRequireUserAssignment = Crm.Config.require_user_assignment();
			// 08/01/2010   Allow dynamic teams to be turned off. 
			bool bEnableDynamicTeams   = Crm.Config.enable_dynamic_teams();
			HttpSessionState Session = HttpContext.Current.Session;
			foreach(DataRowView row in dvFields)
			{
				int    nFIELD_INDEX       = Sql.ToInteger(row["FIELD_INDEX"      ]);
				string sFIELD_TYPE        = Sql.ToString (row["FIELD_TYPE"       ]);
				string sDATA_LABEL        = Sql.ToString (row["DATA_LABEL"       ]);
				string sDATA_FIELD        = Sql.ToString (row["DATA_FIELD"       ]);
				string sDISPLAY_FIELD     = Sql.ToString (row["DISPLAY_FIELD"    ]);
				string sCACHE_NAME        = Sql.ToString (row["CACHE_NAME"       ]);
				bool   bDATA_REQUIRED     = Sql.ToBoolean(row["DATA_REQUIRED"    ]);
				bool   bUI_REQUIRED       = Sql.ToBoolean(row["UI_REQUIRED"      ]);
				string sONCLICK_SCRIPT    = Sql.ToString (row["ONCLICK_SCRIPT"   ]);
				string sFORMAT_SCRIPT     = Sql.ToString (row["FORMAT_SCRIPT"    ]);
				short  nFORMAT_TAB_INDEX  = Sql.ToShort  (row["FORMAT_TAB_INDEX" ]);
				int    nFORMAT_MAX_LENGTH = Sql.ToInteger(row["FORMAT_MAX_LENGTH"]);
				int    nFORMAT_SIZE       = Sql.ToInteger(row["FORMAT_SIZE"      ]);
				int    nFORMAT_ROWS       = Sql.ToInteger(row["FORMAT_ROWS"      ]);
				int    nFORMAT_COLUMNS    = Sql.ToInteger(row["FORMAT_COLUMNS"   ]);
				int    nCOLSPAN           = Sql.ToInteger(row["COLSPAN"          ]);
				// 04/02/2008   Add support for Regular Expression validation. 
				string sFIELD_VALIDATOR_MESSAGE = Sql.ToString (row["FIELD_VALIDATOR_MESSAGE"]);
				string sVALIDATION_TYPE         = Sql.ToString (row["VALIDATION_TYPE"        ]);
				string sREGULAR_EXPRESSION      = Sql.ToString (row["REGULAR_EXPRESSION"     ]);
				string sDATA_TYPE               = Sql.ToString (row["DATA_TYPE"              ]);
				string sMININUM_VALUE           = Sql.ToString (row["MININUM_VALUE"          ]);
				string sMAXIMUM_VALUE           = Sql.ToString (row["MAXIMUM_VALUE"          ]);
				string sCOMPARE_OPERATOR        = Sql.ToString (row["COMPARE_OPERATOR"       ]);
				// 09/01/2009   Add support for a generic module popup. 
				string sMODULE_TYPE       = String.Empty;
				try
				{
					sMODULE_TYPE = Sql.ToString (row["MODULE_TYPE"]);
				}
				catch(Exception ex)
				{
					// 09/01/2009   The MODULE_TYPE is not in the view, then log the error and continue. 
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}
				// 12/24/2008   Each field should be on a new line. 
				nCOLSPAN = 0;
				// 12/27/2008   The data field will need to be in upper case in order for it to be found and saved. 
				sDATA_FIELD    = sDATA_FIELD.ToUpper();
				sDISPLAY_FIELD = sDISPLAY_FIELD.ToUpper();

				// 08/01/2010   To apply ACL Field Security, we need to know if the Module Name, which we will extract from the EditView Name. 
				string sMODULE_NAME = String.Empty;
				string[] arrEDIT_NAME = sEDIT_NAME.Split('.');
				if ( arrEDIT_NAME.Length > 0 )
					sMODULE_NAME = arrEDIT_NAME[0];
				bool bIsReadable  = true;
				bool bIsWriteable = true;
				if ( SplendidInit.bEnableACLFieldSecurity )
				{
					Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, gASSIGNED_USER_ID);
					bIsReadable  = acl.IsReadable();
					bIsWriteable = acl.IsWriteable();
				}
				// 08/01/2010   If not readable, then just skip the field. 
				if ( !bIsReadable )
					continue;

				sDATA_LABEL = m_sMODULE + ".LBL_" + sDATA_FIELD;
				if ( sDATA_FIELD == "TEAM_ID" || sDATA_FIELD == "TEAM_SET_NAME" )
					sDATA_LABEL = "Teams.LBL_TEAM";
				else if ( sDATA_FIELD == "ASSIGNED_USER_ID" )
					sDATA_LABEL = ".LBL_ASSIGNED_TO";

				// 11/25/2006   If Team Management has been disabled, then convert the field to a blank. 
				// Keep the field, but treat it as blank so that field indexes will still be valid. 
				// 12/03/2006   Allow the team field to be visible during layout. 
				if ( sDATA_FIELD == "TEAM_ID" || sDATA_FIELD == "TEAM_SET_NAME" )
				{
					if ( !bEnableTeamManagement )
					{
						sFIELD_TYPE = "Blank";
						bUI_REQUIRED = false;
					}
					else
					{
						if ( bEnableDynamicTeams )
						{
							// 08/31/2009   Don't convert to TeamSelect inside a Search view or Popup view. 
							if ( sEDIT_NAME.IndexOf(".Search") < 0 && sEDIT_NAME.IndexOf(".Popup") < 0 )
							{
								sDATA_LABEL     = ".LBL_TEAM_SET_NAME";
								sDATA_FIELD     = "TEAM_SET_NAME";
								sFIELD_TYPE     = "TeamSelect";
								sONCLICK_SCRIPT = String.Empty;
							}
						}
						else
						{
							// 04/18/2010   If the user manually adds a TeamSelect, we need to convert to a ModulePopup. 
							if ( sFIELD_TYPE == "TeamSelect" )
							{
								sDATA_LABEL     = "Teams.LBL_TEAM";
								sDATA_FIELD     = "TEAM_ID";
								sDISPLAY_FIELD  = "TEAM_NAME";
								sFIELD_TYPE     = "ModulePopup";
								sMODULE_TYPE    = "Teams";
								sONCLICK_SCRIPT = String.Empty;
							}
						}
						// 11/25/2006   Override the required flag with the system value. 
						// 01/01/2008   If Team Management is not required, then let the admin decide. 
						if ( bRequireTeamManagement )
							bUI_REQUIRED = true;
					}
				}
				// 08/01/2010   Hide the Exchange Folder field if disabled for this module or user. 
				if ( sDATA_FIELD == "EXCHANGE_FOLDER" )
				{
					if ( !Crm.Modules.ExchangeFolders(sMODULE_NAME) || !Security.HasExchangeAlias() )
					{
						sFIELD_TYPE = "Blank";
					}
				}
				if ( String.Compare(sFIELD_TYPE, "AddressButtons", true) == 0 )
					continue;
				else if ( String.Compare(sFIELD_TYPE, "Blank", true) == 0 )
					continue;
				else if ( hashIncludedFields != null && !hashIncludedFields.ContainsKey(sDATA_FIELD) )
					continue;

				if ( sDATA_FIELD == "ASSIGNED_USER_ID" )
				{
					// 01/01/2008   We need a quick way to require user assignments across the system. 
					if ( bRequireUserAssignment )
						bUI_REQUIRED = true;
				}
				// 08/01/2010   Clear the Required flag if the field is writeable. 
				// Clearing at this stage will apply it to all edit types. 
				if ( bUI_REQUIRED && !bIsWriteable )
					bUI_REQUIRED = false;
				if ( (nCOLSPAN >= 0 && nColIndex == 0) || tr == null )
				{
					// 12/27/2008   We need an extra row for the set primary and remove links. 
					if ( nRowIndex == 0 && tbl == tblMain )
					{
						if ( tbl.Rows.Count > nRowIndex )
						{
							tr = tbl.Rows[nRowIndex];
						}
						else
						{
							tr = new HtmlTableRow();
							tbl.Rows.Insert(nRowIndex, tr);
						}
						nRowIndex++;
						tdLabel = new HtmlTableCell();
						tdField = new HtmlTableCell();
						tr.Cells.Add(tdLabel);
						tr.Cells.Add(tdField);
						Label lblPrimaryID = new Label();
						tdField.Controls.Add(lblPrimaryID);
						if ( rdr != null )
						{
							Guid gPrimaryID = Sql.ToGuid(rdr["ID"]);
#if DEBUG
							lblPrimaryID.Text = gPrimaryID.ToString();
#endif
						}
					}
					if ( tbl.Rows.Count > nRowIndex )
					{
						tr = tbl.Rows[nRowIndex];
					}
					else
					{
						tr = new HtmlTableRow();
						tbl.Rows.Insert(nRowIndex, tr);
					}
					nRowIndex++;
				}
				// 12/03/2006   Move literal label up so that it can be accessed when processing a blank. 
				Literal litLabel = new Literal();
				if ( !Sql.IsEmptyString(sDATA_FIELD) )
					litLabel.ID = sDATA_FIELD + "_LABEL" + sIDSuffix;
				if ( nCOLSPAN >= 0 || tdLabel == null || tdField == null )
				{
					tdLabel = new HtmlTableCell();
					tdField = new HtmlTableCell();
					tr.Cells.Add(tdLabel);
					tr.Cells.Add(tdField);
					if ( nCOLSPAN > 0 )
					{
						tdField.ColSpan = nCOLSPAN;
					}
					tdLabel.Attributes.Add("class", "dataLabel");
					tdLabel.VAlign = "top";
					tdLabel.Width  = sFIELD_WIDTH;
					tdField.Attributes.Add("class", "dataField");
					tdField.VAlign = "top";
					tdField.Width  = sFIELD_WIDTH;

					tdLabel.Controls.Add(litLabel);
					//litLabel.Text = nFIELD_INDEX.ToString() + " (" + nRowIndex.ToString() + "," + nColIndex.ToString() + ")";
					try
					{
						// 12/03/2006   Move code to blank able in layout mode to blank section below. 
						if ( sDATA_LABEL.IndexOf(".") >= 0 )
							litLabel.Text = L10n.Term(sDATA_LABEL);
						else if ( !Sql.IsEmptyString(sDATA_LABEL) && rdr != null )
						{
							// 01/27/2008   If the data label is not in the schema table, then it must be free-form text. 
							// It is not used often, but we allow the label to come from the result set.  For example,
							// when the parent is stored in the record, we need to pull the module name from the record. 
							litLabel.Text = sDATA_LABEL;
							if ( rdr.DataView.Table.Columns.Contains(sDATA_LABEL) )
								litLabel.Text = Sql.ToString(rdr[sDATA_LABEL]) + L10n.Term("Calls.LBL_COLON");
						}
						// 07/15/2006   Always put something for the label so that table borders will look right. 
						// 07/20/2007 Vandalo.  Skip the requirement to create a terminology entry and just so the label. 
						else
							litLabel.Text = sDATA_LABEL;  // "&nbsp;";
					}
					catch(Exception ex)
					{
						SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						litLabel.Text = ex.Message;
					}
					if ( bUI_REQUIRED )
					{
						Label lblRequired = new Label();
						tdLabel.Controls.Add(lblRequired);
						lblRequired.CssClass = "required";
						lblRequired.Text = L10n.Term(".LBL_REQUIRED_SYMBOL");
					}
				}
				
				if ( String.Compare(sFIELD_TYPE, "Label", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						Literal litField = new Literal();
						tdField.Controls.Add(litField);
						// 07/25/2006   Align label values to the middle so the line-up with the label. 
						tdField.VAlign = "middle";
						// 07/24/2006   Set the ID so that the literal control can be accessed. 
						litField.ID = sDATA_FIELD + sIDSuffix;
						try
						{
							if ( sDATA_FIELD.IndexOf(".") >= 0 )
								litField.Text = L10n.Term(sDATA_FIELD);
							else if ( rdr != null )
								litField.Text = Sql.ToString(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							litField.Text = ex.Message;
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "ListBox", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/02/2007   If format rows > 0 then this is a list box and not a drop down list. 
						ListControl lstField = null;
						if ( nFORMAT_ROWS > 0 )
						{
							ListBox lb = new ListBox();
							lb.SelectionMode = ListSelectionMode.Multiple;
							lb.Rows          = nFORMAT_ROWS;
							lstField = lb;
						}
						else
						{
							// 04/25/2008   Use KeySortDropDownList instead of ListSearchExtender. 
							lstField = new KeySortDropDownList();
							// 07/23/2010   Lets try the latest version of the ListSearchExtender. 
							// 07/28/2010   We are getting an undefined exception on the Accounts List Advanced page. 
							// Lets drop back to using KeySort. 
							//lstField = new DropDownList();
						}
						tdField.Controls.Add(lstField);
						lstField.ID       = sDATA_FIELD + sIDSuffix;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						lstField.Enabled  = bIsWriteable;
						// 07/23/2010   Lets try the latest version of the ListSearchExtender. 
						// 07/28/2010   We are getting an undefined exception on the Accounts List Advanced page. 
						/*
						if ( nFORMAT_ROWS == 0 )
						{
							AjaxControlToolkit.ListSearchExtender extField = new AjaxControlToolkit.ListSearchExtender();
							extField.ID              = lstField.ID + "_ListSearchExtender";
							extField.TargetControlID = lstField.ID;
							extField.PromptText      = L10n.Term(".LBL_TYPE_TO_SEARCH");
							extField.PromptCssClass  = "ListSearchExtenderPrompt";
							tdField.Controls.Add(extField);
						}
						*/
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) )
							{
								// 12/04/2005   Don't populate list if this is a post back. 
								if ( !Sql.IsEmptyString(sCACHE_NAME) && (!bIsPostBack) )
								{
									// 12/24/2007   Use an array to define the custom caches so that list is in the Cache module. 
									// This should reduce the number of times that we have to edit the SplendidDynamic module. 
									// 02/16/2012   Move custom cache logic to a method. 
									SplendidCache.SetListSource(sCACHE_NAME, lstField);
									lstField.DataBind();
									// 08/08/2006   Allow onchange code to be stored in the database.  
									// ListBoxes do not have a useful onclick event, so there should be no problem overloading this field. 
									if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
										lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
									// 02/21/2006   Move the NONE item inside the !IsPostBack code. 
									// 12/02/2007   We don't need a NONE record when using multi-selection. 
									// 12/03/2007   We do want the NONE record when using multi-selection. 
									// This will allow searching of fields that are null instead of using the unassigned only checkbox. 
									if ( !bUI_REQUIRED )
									{
										lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
										// 12/02/2007   AppendEditViewFields should be called inside Page_Load when not a postback, 
										// and in InitializeComponent when it is a postback. If done wrong, 
										// the page will bind after the list is populated, causing the list to populate again. 
										// This event will cause the NONE entry to be cleared.  Add a handler to catch this problem, 
										// but the real solution is to call AppendEditViewFields at the appropriate times based on the postback event. 
										lstField.DataBound += new EventHandler(SplendidDynamic.ListControl_DataBound_AllowNull);
									}
								}
								if ( rdr != null )
								{
									try
									{
										// 02/21/2006   All the DropDownLists in the Calls and Meetings edit views were not getting set.  
										// The problem was a Page.DataBind in the SchedulingGrid and in the InviteesView. Both binds needed to be removed. 
										// 12/30/2007   A customer needed the ability to save and restore the multiple selection. 
										// 12/30/2007   Require the XML declaration in the data before trying to treat as XML. 
										string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
										if ( nFORMAT_ROWS > 0 && sVALUE.StartsWith("<?xml") )
										{
											XmlDocument xml = new XmlDocument();
											xml.LoadXml(sVALUE);
											XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
											foreach ( XmlNode xValue in nlValues )
											{
												foreach ( ListItem item in lstField.Items )
												{
													if ( item.Value == xValue.InnerText )
														item.Selected = true;
												}
											}
										}
										else
										{
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetSelectedValue(lstField, sVALUE);
										}
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				// 08/21/2010   Add support for Radio buttons. 
				else if ( String.Compare(sFIELD_TYPE, "Radio", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						ListControl lstField = new RadioButtonList();
						tdField.Controls.Add(lstField);
						lstField.ID       = sDATA_FIELD + sIDSuffix;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						lstField.CssClass = "radio";
						// 08/01/2010   Apply ACL Field Security. 
						lstField.Enabled  = bIsWriteable;
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) )
							{
								// 12/04/2005   Don't populate list if this is a post back. 
								if ( !Sql.IsEmptyString(sCACHE_NAME) && (!bIsPostBack) )
								{
									// 12/24/2007   Use an array to define the custom caches so that list is in the Cache module. 
									// This should reduce the number of times that we have to edit the SplendidDynamic module. 
									// 02/16/2012   Move custom cache logic to a method. 
									SplendidCache.SetListSource(sCACHE_NAME, lstField);
									lstField.DataBind();
									if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
										lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
									if ( !bUI_REQUIRED )
									{
										lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
										lstField.DataBound += new EventHandler(SplendidDynamic.ListControl_DataBound_AllowNull);
									}
								}
								if ( rdr != null )
								{
									try
									{
										string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
										if ( sVALUE.StartsWith("<?xml") )
										{
											XmlDocument xml = new XmlDocument();
											xml.LoadXml(sVALUE);
											XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
											foreach ( XmlNode xValue in nlValues )
											{
												foreach ( ListItem item in lstField.Items )
												{
													if ( item.Value == xValue.InnerText )
														item.Selected = true;
												}
											}
										}
										else
										{
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetSelectedValue(lstField, sVALUE);
										}
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				// 08/21/2010   Add support for CheckBoxList. 
				else if ( String.Compare(sFIELD_TYPE, "CheckBoxList", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/02/2007   If format rows > 0 then this is a list box and not a drop down list. 
						ListControl lstField = new CheckBoxList();
						tdField.Controls.Add(lstField);
						lstField.ID       = sDATA_FIELD + sIDSuffix;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						lstField.CssClass = "checkbox";
						// 08/01/2010   Apply ACL Field Security. 
						lstField.Enabled  = bIsWriteable;
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) )
							{
								// 12/04/2005   Don't populate list if this is a post back. 
								if ( !Sql.IsEmptyString(sCACHE_NAME) && (!bIsPostBack) )
								{
									// 12/24/2007   Use an array to define the custom caches so that list is in the Cache module. 
									// This should reduce the number of times that we have to edit the SplendidDynamic module. 
									// 02/16/2012   Move custom cache logic to a method. 
									SplendidCache.SetListSource(sCACHE_NAME, lstField);
									lstField.DataBind();
									if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
										lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
								}
								if ( rdr != null )
								{
									try
									{
										string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
										if ( sVALUE.StartsWith("<?xml") )
										{
											XmlDocument xml = new XmlDocument();
											xml.LoadXml(sVALUE);
											XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
											foreach ( XmlNode xValue in nlValues )
											{
												foreach ( ListItem item in lstField.Items )
												{
													if ( item.Value == xValue.InnerText )
														item.Selected = true;
												}
											}
										}
										else
										{
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetSelectedValue(lstField, sVALUE);
										}
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "CheckBox", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						CheckBox chkField = new CheckBox();
						tdField.Controls.Add(chkField);
						chkField.ID = sDATA_FIELD + sIDSuffix;
						chkField.CssClass = "checkbox";
						chkField.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						chkField.Enabled  = bIsWriteable;
						try
						{
							if ( rdr != null )
								chkField.Checked = Sql.ToBoolean(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						// 07/11/2007   A checkbox can have a click event. 
						if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
							chkField.Attributes.Add("onclick", sONCLICK_SCRIPT);
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "ChangeButton", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						//05/06/2010   Manually generate ClearModuleType so that it will be UpdatePanel safe. 
						DropDownList lstField = null;
						// 12/04/2005   If the label is PARENT_TYPE, then change the label to a DropDownList.
						if ( sDATA_LABEL == "PARENT_TYPE" )
						{
							tdLabel.Controls.Clear();
							// 04/25/2008   Use KeySortDropDownList instead of ListSearchExtender. 
							lstField = new KeySortDropDownList();
							// 07/23/2010   Lets try the latest version of the ListSearchExtender. 
							// 07/28/2010   We are getting an undefined exception on the Accounts List Advanced page. 
							// Lets drop back to using KeySort. 
							//lstField = new DropDownList();
							tdLabel.Controls.Add(lstField);
							lstField.ID       = sDATA_LABEL + sIDSuffix;
							lstField.TabIndex = nFORMAT_TAB_INDEX;
							// 07/23/2010   Lets try the latest version of the ListSearchExtender. 
							// 07/28/2010   We are getting an undefined exception on the Accounts List Advanced page. 
							/*
							if ( nFORMAT_ROWS == 0 )
							{
								AjaxControlToolkit.ListSearchExtender extField = new AjaxControlToolkit.ListSearchExtender();
								extField.ID              = lstField.ID + "_ListSearchExtender";
								extField.TargetControlID = lstField.ID;
								extField.PromptText      = L10n.Term(".LBL_TYPE_TO_SEARCH");
								extField.PromptCssClass  = "ListSearchExtenderPrompt";
								tdLabel.Controls.Add(extField);
							}
							*/
							if ( !bIsPostBack )
							{
								// 07/29/2005   SugarCRM 3.0 does not allow the NONE option. 
								lstField.DataValueField = "NAME"        ;
								lstField.DataTextField  = "DISPLAY_NAME";
								lstField.DataSource     = SplendidCache.List("record_type_display");
								lstField.DataBind();
								if ( rdr != null )
								{
									try
									{
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetSelectedValue(lstField, Sql.ToString(rdr[sDATA_LABEL]));
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						TextBox txtNAME = new TextBox();
						tdField.Controls.Add(txtNAME);
						txtNAME.ID       = sDISPLAY_FIELD + sIDSuffix;
						txtNAME.ReadOnly = true;
						txtNAME.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						txtNAME.Enabled  = bIsWriteable;
						// 11/25/2006    Turn off viewstate so that we can fix the text on postback. 
						txtNAME.EnableViewState = false;
						try
						{
							if ( bIsPostBack )
							{
								// 11/25/2006   In order for this posback fix to work, viewstate must be disabled for this field. 
								if ( tbl.Page.Request[txtNAME.UniqueID] != null )
									txtNAME.Text = Sql.ToString(tbl.Page.Request[txtNAME.UniqueID]);
							}
							else if ( !Sql.IsEmptyString(sDISPLAY_FIELD) && rdr != null )
								txtNAME.Text = Sql.ToString(rdr[sDISPLAY_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						HtmlInputHidden hidID = new HtmlInputHidden();
						tdField.Controls.Add(hidID);
						hidID.ID = sDATA_FIELD + sIDSuffix;
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
								hidID.Value = Sql.ToString(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						//05/06/2010   Manually generate ClearModuleType so that it will be UpdatePanel safe. 
						// 07/27/2010   Add the ability to submit after clear. 
						if ( sDATA_LABEL == "PARENT_TYPE" && lstField != null )
							lstField.Attributes.Add("onChange", "ClearModuleType('', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', false);");
						
						Literal litNBSP = new Literal();
						tdField.Controls.Add(litNBSP);
						litNBSP.Text = "&nbsp;";
						
						HtmlInputButton btnChange = new HtmlInputButton("button");
						tdField.Controls.Add(btnChange);
						// 05/07/2006   Specify a name for the check button so that it can be referenced by SplendidTest. 
						btnChange.ID = sDATA_FIELD + "_btnChange" + sIDSuffix;
						btnChange.Attributes.Add("class", "button");
						//05/06/2010   Manually generate ParentPopup so that it will be UpdatePanel safe. 
						if ( lstField != null )
							btnChange.Attributes.Add("onclick", "return ModulePopup(document.getElementById('" + lstField.ClientID + "').options[document.getElementById('" + lstField.ClientID + "').options.selectedIndex].value, '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', null, false, null);");
						else if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
							btnChange.Attributes.Add("onclick"  , sONCLICK_SCRIPT);
						// 03/31/2007   SugarCRM now uses Select instead of Change. 
						btnChange.Attributes.Add("title"    , L10n.Term(".LBL_SELECT_BUTTON_TITLE"));
						// 07/31/2006   Stop using VisualBasic library to increase compatibility with Mono. 
						// 03/31/2007   Stop using AccessKey for change button. 
						//btnChange.Attributes.Add("accessKey", L10n.Term(".LBL_SELECT_BUTTON_KEY").Substring(0, 1));
						btnChange.Value = L10n.Term(".LBL_SELECT_BUTTON_LABEL");
						// 08/01/2010   Apply ACL Field Security. 
						btnChange.Disabled = !bIsWriteable;

						// 12/03/2007   Also create a Clear button. 
						// 05/06/2010   A Parent Type will always have a clear button. 
						if ( sONCLICK_SCRIPT.IndexOf("Popup();") > 0 || sDATA_LABEL == "PARENT_TYPE" )
						{
							litNBSP = new Literal();
							tdField.Controls.Add(litNBSP);
							litNBSP.Text = "&nbsp;";
							
							HtmlInputButton btnClear = new HtmlInputButton("button");
							tdField.Controls.Add(btnClear);
							btnClear.ID = sDATA_FIELD + "_btnClear" + sIDSuffix;
							btnClear.Attributes.Add("class", "button");
							//05/06/2010   Manually generate ClearModuleType so that it will be UpdatePanel safe. 
							// 07/27/2010   Add the ability to submit after clear. 
							btnClear.Attributes.Add("onclick"  , "return ClearModuleType('', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', false);");
							btnClear.Attributes.Add("title"    , L10n.Term(".LBL_CLEAR_BUTTON_TITLE"));
							btnClear.Value = L10n.Term(".LBL_CLEAR_BUTTON_LABEL");
							// 08/01/2010   Apply ACL Field Security. 
							btnClear.Disabled  = !bIsWriteable;
						}
						if ( bUI_REQUIRED && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidatorForHiddenInputs reqID = new RequiredFieldValidatorForHiddenInputs();
							reqID.ID                 = sDATA_FIELD + "_REQUIRED" + sIDSuffix;
							reqID.ControlToValidate  = hidID.ID;
							reqID.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqID.CssClass           = "required";
							reqID.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqID.EnableClientScript = false;
							reqID.Enabled            = false;
							// 02/21/2008   Add a little padding. 
							reqID.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqID);
						}
					}
				}
				// 09/01/2009   Add support for ModulePopups.
				// 08/01/2010   Lets do the same for ModuleAutoComplete. 
				else if ( String.Compare(sFIELD_TYPE, "ModulePopup", true) == 0 || String.Compare(sFIELD_TYPE, "ModuleAutoComplete", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TextBox txtNAME = new TextBox();
						tdField.Controls.Add(txtNAME);
						// 10/05/2010   A custom field will not have a display field, but we still want to be able to access by name. 
						txtNAME.ID       = (Sql.IsEmptyString(sDISPLAY_FIELD) ? sDATA_FIELD + "_NAME" : sDISPLAY_FIELD) + sIDSuffix;
						txtNAME.ReadOnly = true;
						txtNAME.TabIndex = nFORMAT_TAB_INDEX;
						// 11/25/2006    Turn off viewstate so that we can fix the text on postback. 
						txtNAME.EnableViewState = false;
						// 08/01/2010   Apply ACL Field Security. 
						txtNAME.Enabled  = bIsWriteable;
						try
						{
							if ( bIsPostBack )
							{
								// 11/25/2006   In order for this posback fix to work, viewstate must be disabled for this field. 
								if ( tbl.Page.Request[txtNAME.UniqueID] != null )
									txtNAME.Text = Sql.ToString(tbl.Page.Request[txtNAME.UniqueID]);
							}
							else if ( !Sql.IsEmptyString(sDISPLAY_FIELD) && rdr != null )
								txtNAME.Text = Sql.ToString(rdr[sDISPLAY_FIELD]);
							else if ( rdr != null )
								txtNAME.Text = Crm.Modules.ItemName(Application, sMODULE_TYPE, rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						HtmlInputHidden hidID = new HtmlInputHidden();
						tdField.Controls.Add(hidID);
						hidID.ID = sDATA_FIELD + sIDSuffix;
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
								hidID.Value = Sql.ToString(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						
						Literal litNBSP = new Literal();
						tdField.Controls.Add(litNBSP);
						litNBSP.Text = "&nbsp;";
						
						HtmlInputButton btnChange = new HtmlInputButton("button");
						tdField.Controls.Add(btnChange);
						// 05/07/2006   Specify a name for the check button so that it can be referenced by SplendidTest. 
						btnChange.ID = sDATA_FIELD + "_btnChange" + sIDSuffix;
						btnChange.Attributes.Add("class", "button");
						if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
							btnChange.Attributes.Add("onclick"  , sONCLICK_SCRIPT);
						else
							btnChange.Attributes.Add("onclick"  , "return ModulePopup('" + sMODULE_TYPE + "', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', null, false, null);");
						// 03/31/2007   SugarCRM now uses Select instead of Change. 
						btnChange.Attributes.Add("title"    , L10n.Term(".LBL_SELECT_BUTTON_TITLE"));
						// 07/31/2006   Stop using VisualBasic library to increase compatibility with Mono. 
						// 03/31/2007   Stop using AccessKey for change button. 
						//btnChange.Attributes.Add("accessKey", L10n.Term(".LBL_SELECT_BUTTON_KEY").Substring(0, 1));
						btnChange.Value = L10n.Term(".LBL_SELECT_BUTTON_LABEL");
						// 08/01/2010   Apply ACL Field Security. 
						btnChange.Disabled = !bIsWriteable;

						litNBSP = new Literal();
						tdField.Controls.Add(litNBSP);
						litNBSP.Text = "&nbsp;";
						
						HtmlInputButton btnClear = new HtmlInputButton("button");
						tdField.Controls.Add(btnClear);
						btnClear.ID = sDATA_FIELD + "_btnClear" + sIDSuffix;
						btnClear.Attributes.Add("class", "button");
						// 07/27/2010   Add the ability to submit after clear. 
						btnClear.Attributes.Add("onclick"  , "return ClearModuleType('" + sMODULE_TYPE + "', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', false);");
						btnClear.Attributes.Add("title"    , L10n.Term(".LBL_CLEAR_BUTTON_TITLE"));
						btnClear.Value = L10n.Term(".LBL_CLEAR_BUTTON_LABEL");
						// 08/01/2010   Apply ACL Field Security. 
						btnClear.Disabled = !bIsWriteable;

						if ( bUI_REQUIRED && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidatorForHiddenInputs reqID = new RequiredFieldValidatorForHiddenInputs();
							reqID.ID                 = sDATA_FIELD + "_REQUIRED" + sIDSuffix;
							reqID.ControlToValidate  = hidID.ID;
							reqID.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqID.CssClass           = "required";
							reqID.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqID.EnableClientScript = false;
							reqID.Enabled            = false;
							// 02/21/2008   Add a little padding. 
							reqID.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqID);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "TextBox", true) == 0 || String.Compare(sFIELD_TYPE, "Password", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TextBox txtField = new TextBox();
						tdField.Controls.Add(txtField);
						txtField.ID       = sDATA_FIELD + sIDSuffix;
						txtField.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						txtField.Enabled  = bIsWriteable;
						try
						{
							if ( nFORMAT_ROWS > 0 && nFORMAT_COLUMNS > 0 )
							{
								txtField.Rows     = nFORMAT_ROWS   ;
								txtField.Columns  = nFORMAT_COLUMNS;
								txtField.TextMode = TextBoxMode.MultiLine;
							}
							else
							{
								txtField.MaxLength = nFORMAT_MAX_LENGTH   ;
								txtField.Attributes.Add("size", nFORMAT_SIZE.ToString());
								txtField.TextMode  = TextBoxMode.SingleLine;
							}
							if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
							{
								if ( rdr[sDATA_FIELD].GetType() == typeof(System.Decimal) )
									txtField.Text = Sql.ToDecimal(rdr[sDATA_FIELD]).ToString("#,##0.00");
								else
									txtField.Text = Sql.ToString(rdr[sDATA_FIELD]);
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtField.Text = ex.Message;
						}
						if ( String.Compare(sFIELD_TYPE, "Password", true) == 0 )
							txtField.TextMode = TextBoxMode.Password;
						if ( bUI_REQUIRED && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidator reqNAME = new RequiredFieldValidator();
							reqNAME.ID                 = sDATA_FIELD + "_REQUIRED" + sIDSuffix;
							reqNAME.ControlToValidate  = txtField.ID;
							reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqNAME.CssClass           = "required";
							reqNAME.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqNAME.EnableClientScript = false;
							reqNAME.Enabled            = false;
							reqNAME.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqNAME);
						}
						if ( !Sql.IsEmptyString(sDATA_FIELD) )
						{
							if ( sVALIDATION_TYPE == "RegularExpressionValidator" && !Sql.IsEmptyString(sREGULAR_EXPRESSION) && !Sql.IsEmptyString(sFIELD_VALIDATOR_MESSAGE) && bIsWriteable )
							{
								RegularExpressionValidator reqVALIDATOR = new RegularExpressionValidator();
								reqVALIDATOR.ID                   = sDATA_FIELD + "_VALIDATOR" + sIDSuffix;
								reqVALIDATOR.ControlToValidate    = txtField.ID;
								reqVALIDATOR.ErrorMessage         = L10n.Term(sFIELD_VALIDATOR_MESSAGE);
								reqVALIDATOR.ValidationExpression = sREGULAR_EXPRESSION;
								reqVALIDATOR.CssClass             = "required";
								reqVALIDATOR.EnableViewState      = false;
								// 04/02/2008   We don't enable required fields until we attempt to save. 
								// This is to allow unrelated form actions; the Cancel button is a good example. 
								reqVALIDATOR.EnableClientScript   = false;
								reqVALIDATOR.Enabled              = false;
								reqVALIDATOR.Style.Add("padding-left", "4px");
								tdField.Controls.Add(reqVALIDATOR);
							}
						}
					}
				}
				// 04/04/2011   Add support for HtmlEditor. 
				else if ( String.Compare(sFIELD_TYPE, "HtmlEditor", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 09/18/2011   Upgrade to CKEditor 3.6.2. 
						CKEditorControl txtField = new CKEditorControl();
						tdField.Controls.Add(txtField);
						txtField.ID         = sDATA_FIELD;
						txtField.Toolbar    = "Taoqi";
						// 09/18/2011   Set the language for CKEditor. 
						txtField.Language   = L10n.NAME;
						txtField.BasePath   = "~/ckeditor/";
						// 04/26/2012   Add file uploader. 
						txtField.FilebrowserUploadUrl    = txtField.ResolveUrl("~/ckeditor/upload.aspx");
						txtField.FilebrowserBrowseUrl    = txtField.ResolveUrl("~/Images/Popup.aspx");
						//txtField.FilebrowserWindowWidth  = "640";
						//txtField.FilebrowserWindowHeight = "480";
						txtField.Visible  = bIsWriteable;
						try
						{
							if ( nFORMAT_ROWS > 0 && nFORMAT_COLUMNS > 0 )
							{
								txtField.Height = nFORMAT_ROWS   ;
								// 04/04/2011   Reduce the width to make it easier to edit. 
								txtField.Width  = nFORMAT_COLUMNS / 2;
							}
							if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
							{
								txtField.Text = Sql.ToString(rdr[sDATA_FIELD]);
								// 01/18/2010   FCKEditor does not have an Enable field, so just hide and replace with a Literal control. 
								if ( !bIsWriteable )
								{
									txtField.Visible = false;
									Literal litField = new Literal();
									litField.ID = sDATA_FIELD + "_ReadOnly";
									tdField.Controls.Add(litField);
									litField.Text = Sql.ToString(rdr[sDATA_FIELD]);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtField.Text = ex.Message;
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DatePicker", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DatePicker ctlDate = tbl.Page.LoadControl("~/_controls/DatePicker.ascx") as DatePicker;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD + sIDSuffix;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						ctlDate.Enabled  = bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateRange", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/17/2007   Use table to align before and after labels. 
						Table tblDateRange = new Table();
						tdField.Controls.Add(tblDateRange);
						TableRow trAfter = new TableRow();
						TableRow trBefore = new TableRow();
						tblDateRange.Rows.Add(trAfter);
						tblDateRange.Rows.Add(trBefore);
						TableCell tdAfterLabel  = new TableCell();
						TableCell tdAfterData   = new TableCell();
						TableCell tdBeforeLabel = new TableCell();
						TableCell tdBeforeData  = new TableCell();
						trAfter .Cells.Add(tdAfterLabel );
						trAfter .Cells.Add(tdAfterData  );
						trBefore.Cells.Add(tdBeforeLabel);
						trBefore.Cells.Add(tdBeforeData );

						// 12/03/2005   UserControls must be loaded. 
						DatePicker ctlDateStart = tbl.Page.LoadControl("~/_controls/DatePicker.ascx") as DatePicker;
						DatePicker ctlDateEnd   = tbl.Page.LoadControl("~/_controls/DatePicker.ascx") as DatePicker;
						Literal litAfterLabel  = new Literal();
						Literal litBeforeLabel = new Literal();
						litAfterLabel .Text = L10n.Term("SavedSearch.LBL_SEARCH_AFTER" );
						litBeforeLabel.Text = L10n.Term("SavedSearch.LBL_SEARCH_BEFORE");
						//tdField.Controls.Add(litAfterLabel );
						//tdField.Controls.Add(ctlDateStart  );
						//tdField.Controls.Add(litBeforeLabel);
						//tdField.Controls.Add(ctlDateEnd    );
						tdAfterLabel .Controls.Add(litAfterLabel );
						tdAfterData  .Controls.Add(ctlDateStart  );
						tdBeforeLabel.Controls.Add(litBeforeLabel);
						tdBeforeData .Controls.Add(ctlDateEnd    );

						ctlDateStart.ID = sDATA_FIELD + "_AFTER" + sIDSuffix;
						ctlDateEnd  .ID = sDATA_FIELD + "_BEFORE" + sIDSuffix;
						// 05/10/2006   Set the tab index. 
						ctlDateStart.TabIndex = nFORMAT_TAB_INDEX;
						ctlDateEnd  .TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						ctlDateStart.Enabled  = bIsWriteable;
						ctlDateEnd  .Enabled  = bIsWriteable;
						try
						{
							if ( rdr != null )
							{
								ctlDateStart.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
								ctlDateEnd  .Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateTimePicker", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DateTimePicker ctlDate = tbl.Page.LoadControl("~/_controls/DateTimePicker.ascx") as DateTimePicker;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD + sIDSuffix;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						ctlDate.Enabled  = bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateTimeEdit", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DateTimeEdit ctlDate = tbl.Page.LoadControl("~/_controls/DateTimeEdit.ascx") as DateTimeEdit;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD + sIDSuffix;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						ctlDate.Enabled  = bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bUI_REQUIRED )
						{
							ctlDate.EnableNone = false;
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "File", true) == 0 )
				{
					// 11/23/2010   File should act just like an image. 
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						HtmlInputHidden ctlHidden = null;
						HtmlInputFile   ctlField  = new HtmlInputFile();
						tdField.Controls.Add(ctlField);
						// 04/17/2006   The image needs to reference the file control. 
						// 11/25/2010   Appending _File breaks the previous behavior of Notes, Bugs and Documents.
						// 11/25/2010   The file field is special in that it may not exist as a table column. 
						ctlField.ID = sDATA_FIELD + sIDSuffix;
						if ( rdr != null )
						{
							if ( vwSchema.Contains(sDATA_FIELD) )
							{
								ctlField.ID = sDATA_FIELD + "_File" + sIDSuffix;
								ctlHidden = new HtmlInputHidden();
								tdField.Controls.Add(ctlHidden);
								ctlHidden.ID = sDATA_FIELD + sIDSuffix;
							}
						}
						ctlField.MaxLength = nFORMAT_MAX_LENGTH;
						ctlField.Size      = nFORMAT_SIZE;
						ctlField.Attributes.Add("TabIndex", nFORMAT_TAB_INDEX.ToString());
						// 08/01/2010   Apply ACL Field Security. 
						ctlField.Disabled  = !bIsWriteable;
						if ( bUI_REQUIRED )
						{
							RequiredFieldValidator reqNAME = new RequiredFieldValidator();
							reqNAME.ID                 = sDATA_FIELD + "_REQUIRED" + sIDSuffix;
							reqNAME.ControlToValidate  = ctlField.ID;
							reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqNAME.CssClass           = "required";
							reqNAME.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqNAME.EnableClientScript = false;
							reqNAME.Enabled            = false;
							reqNAME.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqNAME);
						}

						Literal litBR = new Literal();
						litBR.Text = "<br />";
						tdField.Controls.Add(litBR);
						
						HyperLink lnkField = new HyperLink();
						// 04/13/2006   Give the image a name so that it can be validated with SplendidTest. 
						lnkField.ID = "lnk" + sDATA_FIELD + sIDSuffix;
						try
						{
							if ( rdr != null )
							{
								// 11/25/2010   The file field is special in that it may not exist as a table column. 
								if ( ctlHidden != null && !Sql.IsEmptyString(rdr[sDATA_FIELD]) )
								{
									ctlHidden.Value = Sql.ToString(rdr[sDATA_FIELD]);
									lnkField.NavigateUrl = "~/Images/Image.aspx?ID=" + ctlHidden.Value;
									lnkField.Text = Crm.Modules.ItemName(Application, "Images", ctlHidden.Value);
									// 04/13/2006   Only add the image if it exists. 
									tdField.Controls.Add(lnkField);
									
									// 04/17/2006   Provide a clear button. 
									Literal litClear = new Literal();
									litClear.Text = "&nbsp; <input type=\"button\" class=\"button\" onclick=\"document.getElementById('" + ctlHidden.ClientID + "').value='';document.getElementById('" + lnkField.ClientID + "').innerHTML='';" + "\"  value='" + "  " + L10n.Term(".LBL_CLEAR_BUTTON_LABEL" ) + "  " + "' title='" + L10n.Term(".LBL_CLEAR_BUTTON_TITLE" ) + "' />";
									tdField.Controls.Add(litClear);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							Literal litField = new Literal();
							litField.Text = ex.Message;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "Image", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						HtmlInputHidden ctlHidden = new HtmlInputHidden();
						tdField.Controls.Add(ctlHidden);
						ctlHidden.ID = sDATA_FIELD + sIDSuffix;

						HtmlInputFile ctlField = new HtmlInputFile();
						tdField.Controls.Add(ctlField);
						// 04/17/2006   The image needs to reference the file control. 
						ctlField.ID = sDATA_FIELD + "_File" + sIDSuffix;
						ctlField.MaxLength = nFORMAT_MAX_LENGTH;
						ctlField.Size      = nFORMAT_SIZE;
						ctlField.Attributes.Add("TabIndex", nFORMAT_TAB_INDEX.ToString());
						// 08/01/2010   Apply ACL Field Security. 
						ctlField.Disabled  = !bIsWriteable;
						if ( bUI_REQUIRED )
						{
							RequiredFieldValidator reqNAME = new RequiredFieldValidator();
							reqNAME.ID                 = sDATA_FIELD + "_REQUIRED" + sIDSuffix;
							reqNAME.ControlToValidate  = ctlField.ID;
							reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqNAME.CssClass           = "required";
							reqNAME.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqNAME.EnableClientScript = false;
							reqNAME.Enabled            = false;
							reqNAME.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqNAME);
						}

						Literal litBR = new Literal();
						litBR.Text = "<br />";
						tdField.Controls.Add(litBR);
						
						Image imgField = new Image();
						// 04/13/2006   Give the image a name so that it can be validated with SplendidTest. 
						imgField.ID = "img" + sDATA_FIELD + sIDSuffix;
						try
						{
							if ( rdr != null )
							{
								if ( !Sql.IsEmptyString(rdr[sDATA_FIELD]) )
								{
									ctlHidden.Value = Sql.ToString(rdr[sDATA_FIELD]);
									imgField.ImageUrl = "~/Images/Image.aspx?ID=" + ctlHidden.Value;
									// 04/13/2006   Only add the image if it exists. 
									tdField.Controls.Add(imgField);
									
									// 04/17/2006   Provide a clear button. 
									Literal litClear = new Literal();
									litClear.Text = "&nbsp; <input type=\"button\" class=\"button\" onclick=\"document.getElementById('" + ctlHidden.ClientID + "').value='';document.getElementById('" + imgField.ClientID + "').src='';" + "\"  value='" + "  " + L10n.Term(".LBL_CLEAR_BUTTON_LABEL" ) + "  " + "' title='" + L10n.Term(".LBL_CLEAR_BUTTON_TITLE" ) + "' />";
									tdField.Controls.Add(litClear);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							Literal litField = new Literal();
							litField.Text = ex.Message;
							tdField.Controls.Add(litField);
						}
					}
				}
				// 04/04/2011   Add support for hidden field. 
				else if ( String.Compare(sFIELD_TYPE, "Hidden", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						HtmlInputHidden hidID = new HtmlInputHidden();
						tdField.Controls.Add(hidID);
						hidID.ID = sDATA_FIELD + sIDSuffix;
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
								hidID.Value = Sql.ToString(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				// 08/01/2010   Add support for dynamic teams. 
				else if ( String.Compare(sFIELD_TYPE, "TeamSelect", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TeamSelect ctlTeamSelect = tbl.Page.LoadControl("~/_controls/TeamSelect.ascx") as TeamSelect;
						tdField.Controls.Add(ctlTeamSelect);
						ctlTeamSelect.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlTeamSelect.NotPostBack = !bIsPostBack;
						//ctlTeamSelect.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						ctlTeamSelect.Enabled  = bIsWriteable;
						try
						{
							Guid gTEAM_SET_ID = Guid.Empty;
							if ( rdr != null )
							{
								if ( vwSchema.Contains("TEAM_SET_ID") )
								{
									gTEAM_SET_ID = Sql.ToGuid(rdr["TEAM_SET_ID"]);
								}
							}
							// 08/31/2009  Don't provide defaults in a Search view or a Popup view. 
							bool bAllowDefaults = sEDIT_NAME.IndexOf(".Search") < 0 && sEDIT_NAME.IndexOf(".Popup") < 0;
							ctlTeamSelect.LoadLineItems(gTEAM_SET_ID, bAllowDefaults);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				// 04/04/2011   Add support for dynamic teams. 
				else if ( String.Compare(sFIELD_TYPE, "KBTagSelect", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						KBTagSelect ctlKBTagSelect = tbl.Page.LoadControl("~/_controls/KBTagSelect.ascx") as KBTagSelect;
						tdField.Controls.Add(ctlKBTagSelect);
						ctlKBTagSelect.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlKBTagSelect.NotPostBack = !bIsPostBack;
						//ctlTeamSelect.TabIndex = nFORMAT_TAB_INDEX;
						// 08/01/2010   Apply ACL Field Security. 
						ctlKBTagSelect.Enabled  = bIsWriteable;
						try
						{
							Guid gID = Guid.Empty;
							if ( rdr != null )
							{
								gID = Sql.ToGuid(rdr["ID"]);
							}
							ctlKBTagSelect.LoadLineItems(gID);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				else
				{
					Literal litField = new Literal();
					tdField.Controls.Add(litField);
					litField.Text = "Unknown field type " + sFIELD_TYPE;
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), "Unknown field type " + sFIELD_TYPE);
				}
				nColIndex = 0;
			}
		}
Exemple #28
0
        public void ShowForm(WC.Panel panel)
        {
            WC.Table     formTbl       = new WC.Table();
            WC.TableCell mainPathLabel = new WC.TableCell();
            mainPathLabel.Text = "Full size image directory";
            WC.TableCell thumbPathLabel = new WC.TableCell();
            thumbPathLabel.Text = "Thumbnail image directory";
            WC.TableCell mainWidthLabel = new WC.TableCell();
            mainWidthLabel.Text = "Maximum width for the main image";
            WC.TableCell thumbWidthLabel = new WC.TableCell();
            thumbWidthLabel.Text = "Maximum width for the thumbnail";
            WC.TableCell useThumbsLabel = new WC.TableCell();
            useThumbsLabel.Text = "Use thumbnails";
            WC.TableCell targetFormatLabel = new WC.TableCell();
            targetFormatLabel.Text = "Convert images to format";

            WC.TableCell mainPathCell = new WC.TableCell();
            mainPathCell.Controls.Add(mainPathBox);
            WC.TableCell thumbPathCell = new WC.TableCell();
            thumbPathCell.Controls.Add(thumbPathBox);
            WC.TableCell mainWidthCell = new WC.TableCell();
            mainWidthCell.Controls.Add(fullWidthBox);
            WC.TableCell thumbWidthCell = new WC.TableCell();
            thumbWidthCell.Controls.Add(thumbWidthBox);
            WC.TableCell useThumbsCell = new WC.TableCell();
            useThumbsCell.Controls.Add(useThumbsCheck);
            WC.TableCell targetFormatCell = new WC.TableCell();
            targetFormatCell.Controls.Add(targetFormatRadios);

            WC.TableRow r1 = new WC.TableRow();
            r1.Cells.Add(mainPathLabel);
            r1.Cells.Add(mainPathCell);
            formTbl.Rows.Add(r1);

            WC.TableRow r2 = new WC.TableRow();
            r2.Cells.Add(thumbPathLabel);
            r2.Cells.Add(thumbPathCell);
            formTbl.Rows.Add(r2);

            WC.TableRow r3 = new WC.TableRow();
            r3.Cells.Add(mainWidthLabel);
            r3.Cells.Add(mainWidthCell);
            formTbl.Rows.Add(r3);

            WC.TableRow r4 = new WC.TableRow();
            r4.Cells.Add(thumbWidthLabel);
            r4.Cells.Add(thumbWidthCell);
            formTbl.Rows.Add(r4);

            WC.TableRow r5 = new WC.TableRow();
            r5.Cells.Add(useThumbsLabel);
            r5.Cells.Add(useThumbsCell);
            formTbl.Rows.Add(r5);

            WC.TableRow r6 = new WC.TableRow();
            r6.Cells.Add(targetFormatLabel);
            r6.Cells.Add(targetFormatCell);
            formTbl.Rows.Add(r6);

            targetFormatRadios.DataSource = Enum.GetValues(typeof(TargetImageFormat));
            targetFormatRadios.DataBind();

            panel.Controls.Add(formTbl);
        }
 /// <summary>
 /// Renders the control in the designer
 /// </summary>
 public void RenderAtDesignTime()
 {
     if (this._isDesignTime)
     {
         this.Controls.Clear();
         if (this.SurveyId == -1)
         {
             Literal child = new Literal();
             child.Text = "Please set the SurveyId property first!";
             this.Controls.Add(child);
         }
         else
         {
             ArrayList list = new ArrayList();
             list.Add("#Answer 1#");
             list.Add("#Answer 2#");
             list.Add("#Answer 3#");
             list.Add("#Answer 4#");
             list.Add("#Answer 5#");
             Table table = new Table();
             new TableRow();
             new TableCell();
             TableRow row = new TableRow();
             TableCell cell = new TableCell();
             Button button = new Button();
             Button button2 = new Button();
             PlaceHolder holder = new PlaceHolder();
             new Literal();
             table.Rows.Add(this.BuildRow("Error Message", this.QuestionValidationMessageStyle));
             table.Rows.Add(this.BuildRow("Confirmation message", this.ConfirmationMessageStyle));
             row.ControlStyle.CopyFrom(this.QuestionStyle);
             cell.Controls.Add(new LiteralControl("1. #Question#"));
             Label label = new Label();
             label.Text = this.QuestionValidationMark;
             label.ControlStyle.CopyFrom(this.QuestionValidationMarkStyle);
             cell.Controls.Add(label);
             row.Cells.Add(cell);
             table.Rows.Add(row);
             RadioButtonList list2 = new RadioButtonList();
             list2.Width = Unit.Percentage(100.0);
             list2.DataSource = list;
             list2.ControlStyle.CopyFrom(this.AnswerStyle);
             list2.DataBind();
             table.Rows.Add(this.BuildRow(list2, this.AnswerStyle));
             button.ControlStyle.CopyFrom(this.ButtonStyle);
             button.Text = (this.ButtonText == null) ? "Submit" : this.ButtonText;
             button2.ControlStyle.CopyFrom(this.ButtonStyle);
             button2.Text = (this.NextPageText == null) ? "Next page >>" : this.NextPageText;
             holder.Controls.Add(button);
             holder.Controls.Add(button2);
             holder.Controls.Add(new LiteralControl(string.Format("Page {0} / {1}", 1, 10)));
             table.Rows.Add(this.BuildRow(holder, this.FootStyle));
             table.CellPadding = this.CellPadding;
             table.CellSpacing = this.CellSpacing;
             table.Width = base.Width;
             table.Height = base.Height;
             table.BackColor = base.BackColor;
             this.Controls.Add(table);
         }
     }
 }
Exemple #30
0
 public AddForm AddRadioList(List<ListItem> obj, string varId, string script, string index)
 {
     AddForm panel = AddDiv("radio margin-content");
     Label label = new Label();
     RadioButtonList radio = new RadioButtonList();
     radio.Attributes.Add("onchange", script);
     radio.DataTextField = "Text";
     radio.DataValueField = "Value";
     if (!string.IsNullOrEmpty(index))
     {
         radio.SelectedIndex = Convert.ToInt32(index);
     }
     radio.DataSource = obj;
     radio.DataBind();
     HiddenField hidd = new HiddenField();
     hidd.Value = varId;
     panel.Controls.Add(hidd);
     label.Controls.Add(radio);
     panel.Controls.Add(label);
     return panel;
 }
        public void TestCreate()
        {
            OrganizationDetailPanel testpage = new OrganizationDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(testpage);

            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                #region Setup the pre-required data
                //Setup the right URL
                httpEnv.SetRequestUrl("/OrganizationDetailPanel/DynamicPage.svc?Domain=Department");

                //Binding the required web controls
                TextBox organizationCode = new TextBox();
                organizationCode.Text = "123456" + surfix;
                proxy.Set("TextBoxOrganizationCode", organizationCode);

                TextBox organizationName = new TextBox();
                organizationName.Text = "testOrganization" + surfix;
                proxy.Set("TextBoxOrganizationName", organizationName);

                DropDownList DropDownListOrganizationType = new DropDownList();
                var typeData = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId);

                DropDownListOrganizationType.Items.Clear();
                DropDownListOrganizationType.DataSource = typeData;
                DropDownListOrganizationType.DataBind();
                DropDownListOrganizationType.SelectedIndex = 1;

                proxy.Set("DropDownListOrganizationType", DropDownListOrganizationType);

                Array statusData = new string[] { "Enabled", "Disabled", "Pending" };
                RadioButtonList RadioButtonListOrganizationStatus = new RadioButtonList();
                RadioButtonListOrganizationStatus.DataSource = statusData;
                RadioButtonListOrganizationStatus.DataBind();
                RadioButtonListOrganizationStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListOrganizationStatus", RadioButtonListOrganizationStatus);
                #endregion

                //call the Create Method
                string entityId = proxy.Create();
                //Get the created object
                OrganizationObject organization = organizationApi.GetOrganization(new Guid(entityId));

                Assert.AreEqual(organization.OrganizationName, "testOrganization"+surfix);

                createdOrganizationIds.Add(new Guid(entityId));
            }
        }
        public void TestCreate()
        {
            ConcreteDataDetailPanel page = new ConcreteDataDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

            IConcreteDataApi concreteDataApi = SpringContext.Current.GetObject<IConcreteDataApi>();
            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/ConcreteDataDetailPanel/DynamicPage.svc?ConcreteDataType=Department");
                #region Bind Control
                Guid guid = Guid.NewGuid();

                string surfix = guid.ToString().Substring(0, 5);
                TextBox TextBoxName = new TextBox();
                TextBoxName.Text = "concrete" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                TextBox TextBoxValue = new TextBox();
                TextBoxValue.Text = "concrete" + surfix;
                proxy.Set("TextBoxValue", TextBoxValue);

                TextBox TextBoxDescription = new TextBox();
                TextBoxDescription.Text = "concrete" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                Array statusData = new string[] { "NotDeleted", "Deleted" };
                RadioButtonList RadioButtonListStatus = new RadioButtonList();
                RadioButtonListStatus.DataSource = statusData;
                RadioButtonListStatus.DataBind();
                RadioButtonListStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListStatus", RadioButtonListStatus);

                proxy.Set("ExtensionDataForm", null);
                #endregion

                string entityId = proxy.Create();
                ids.Add(new Guid(entityId));

                ConcreteDataObject obj = concreteDataApi.GetById(new Guid(entityId));
                Assert.AreEqual(obj.Name, "concrete" + surfix);

            }
        }
Exemple #33
0
 public void FillToRadioList(RadioButtonList radiolist, DataTable datatable, string displayMember, string valueMember, string selectedIndex)
 {
     if (datatable != null)
     {
         radiolist.DataSource = datatable;
         radiolist.DataTextField = displayMember;
         radiolist.DataValueField = valueMember;
     }
     else
     {
         radiolist.DataSource = null;
     }
     radiolist.DataBind();
     if (selectedIndex != "")
     {
         try
         {
             radiolist.SelectedValue = selectedIndex;
         }
         catch (Exception ex)
         {
             throw new BusinessException(ex.Message.ToString());
         }
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            DateTime dtCurrentDate;

            try
            {
                SourcePageName = "wo_editAddInfo.aspx.cs";

                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (Request.QueryString["id"] == null || Request.QueryString["equipid"] == null)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    EquipId = Convert.ToInt32(Request.QueryString["equipid"]);
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                if (EquipId == 0 && OrderId == 0)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"]    = _functions.ErrorMessage(102);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                m_sLastPage = "wo_editAddInfo.aspx?id=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                if (Request.QueryString["back"] != null)
                {
                    if (Request.QueryString["back"] == "past")
                    {
                        IsPast         = true;
                        this.PageTitle = "Create the Past Work Order";
                        m_sLastPage    = "wo_editAddInfo.aspx?back=past&id=" + OrderId.ToString() + "&equipid=" + EquipId.ToString();
                    }
                }

                NextBackControl.BackVisible = false;
                if (!IsPostBack)
                {
                    dtCurrentDate = DateTime.Now;
                    // getting the main (fixed) data
                    order = new clsWorkOrders();

                    rblWOTypes.DataSource = order.GetTypesList();
                    rblWOTypes.DataBind();

                    order.iOrgId   = OrgId;
                    order.iEquipId = EquipId;
                    order.iId      = OrderId;

                    if (order.GetInfoForWorkOrder() == -1)
                    {
                        Session["lastpage"] = "wo_default.aspx";
                        Session["error"]    = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblEquipId.Text = order.sEquipId.Value;
                    if (order.iTypeId.Value != 0)
                    {
                        rblWOTypes.SelectedValue = order.iTypeId.Value.ToString();
                    }
                    if (!order.daScheduled.IsNull)
                    {
                        adtScheduled.Date = order.daScheduled.Value;
                    }
                    else
                    {
                        adtScheduled.Date = dtCurrentDate.AddMinutes(60 - dtCurrentDate.Minute);
                    }

                    if (OrderId != 0)
                    {
                        order.cAction     = "S";
                        order.iNoteId     = 0;
                        order.iNoteTypeId = (int)NoteTypes.CreationNote;
                        order.iItemId     = OrderId;
                        if (order.NoteDetails() != -1)
                        {
                            tbNotes.Text        = order.sNote.Value;
                            ViewState["NoteId"] = order.iNoteId.Value;
                        }
                        else
                        {
                            ViewState["NoteId"] = 0;
                        }
                    }
                    else
                    {
                        ViewState["NoteId"] = 0;
                    }

                    ShowCustomFields();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "wo_default.aspx";
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (user != null)
                {
                    user.Dispose();
                }
                if (order != null)
                {
                    order.Dispose();
                }
                if (equip != null)
                {
                    equip.Dispose();
                }
            }
        }
        public void TestUpdate()
        {
            OrganizationDetailPanel testpage = new OrganizationDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(testpage);

            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            Guid guid = Guid.NewGuid();

            string surfix = guid.ToString().Substring(0, 5);

            using (var httpEnv = new HttpEnvironment())
            {
                #region Setup the pre-required data
                //Setup the right URL
                httpEnv.SetRequestUrl("/OrganizationDetailPanel/DynamicPage.svc?Domain=Department");

                OrganizationObject testOrganization = new OrganizationObject()
                {
                    OrganizationCode = "78903"+surfix,
                    OrganizationName = "testOrganizationUpdate" + surfix,
                    OrganizationTypeId = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId).FirstOrDefault(),
                    Status = OrganizationStatus.Enabled
                };

                organizationApi.Save(testOrganization);
                createdOrganizationIds.Add(testOrganization.OrganizationId);

                #endregion

                OrganizationObject organization = organizationApi.GetOrganizationByName("testOrganizationUpdate"+surfix);

                #region Setup the Updated Code
                //Binding the required web controls
                TextBox organizationCode = new TextBox();
                organizationCode.Text = "78903" + surfix;
                proxy.Set("TextBoxOrganizationCode", organizationCode);

                TextBox organizationName = new TextBox();
                organizationName.Text = "OrganziationTest" + surfix;
                proxy.Set("TextBoxOrganizationName", organizationName);

                DropDownList DropDownListOrganizationType = new DropDownList();
                var typeData = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId);

                DropDownListOrganizationType.Items.Clear();
                DropDownListOrganizationType.DataSource = typeData;
                DropDownListOrganizationType.DataBind();
                DropDownListOrganizationType.SelectedIndex = 1;

                proxy.Set("DropDownListOrganizationType", DropDownListOrganizationType);

                Array statusData = new string[] { "Enabled", "Disabled", "Pending" };
                RadioButtonList RadioButtonListOrganizationStatus = new RadioButtonList();
                RadioButtonListOrganizationStatus.DataSource = statusData;
                RadioButtonListOrganizationStatus.DataBind();
                RadioButtonListOrganizationStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListOrganizationStatus", RadioButtonListOrganizationStatus);
                #endregion
                proxy.Update(organization.OrganizationId.ToString());

                OrganizationObject organizationUpdated = organizationApi.GetOrganization(organization.OrganizationId);

                Assert.AreNotEqual(organizationUpdated.OrganizationName, "testOrganization" + surfix);
                Assert.AreEqual(organizationUpdated.OrganizationName, "OrganziationTest" + surfix);
            }
        }
Exemple #36
0
		public static void AppendEditViewFields(DataView dvFields, HtmlTable tbl, DataRow rdr, L10N L10n, TimeZone T10n, CommandEventHandler Page_Command, bool bLayoutMode, string sSubmitClientID)
		{
			bool bIsMobile = false;
			SplendidPage Page = tbl.Page as SplendidPage;
			if ( Page != null )
				bIsMobile = Page.IsMobile;
			// 06/21/2009   We need the script manager to properly register EnterKey presses for text boxes. 
			ScriptManager mgrAjax = ScriptManager.GetCurrent(tbl.Page);
			// 11/23/2009   Taoqi 4.0 is very slow on Blackberry devices.  Lets try and turn off AJAX AutoComplete. 
			bool bAjaxAutoComplete = (mgrAjax != null);
			// 12/07/2009   The Opera Mini browser does not support popups. Use a DropdownList instead. 
			bool bSupportsPopups = true;
			if ( bIsMobile )
			{
				// 11/24/2010   .NET 4 has broken the compatibility of the browser file system. 
				// We are going to minimize our reliance on browser files in order to reduce deployment issues. 
				bAjaxAutoComplete = Utils.AllowAutoComplete && (mgrAjax != null);
				bSupportsPopups = Utils.SupportsPopups;
			}
			// 07/28/2010   Save AjaxAutoComplete and SupportsPopups for use in TeamSelect and KBSelect. 
			// We are having issues with the data binding event occurring before the page load. 
			Page.Items["AjaxAutoComplete"] = bAjaxAutoComplete;
			Page.Items["SupportsPopups"  ] = bSupportsPopups  ;
			// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
			bool bIsPostBack = tbl.Page.IsPostBack;
			bool bNotPostBack = false;
			if ( tbl.TemplateControl is SplendidControl )
			{
				bNotPostBack = (tbl.TemplateControl as SplendidControl).NotPostBack;
				bIsPostBack = tbl.Page.IsPostBack && !bNotPostBack;
			}

			HtmlTableRow tr = null;
			// 11/28/2005   Start row index using the existing count so that headers can be specified. 
			int nRowIndex = tbl.Rows.Count - 1;
			int nColIndex = 0;
			HtmlTableCell tdLabel = null;
			HtmlTableCell tdField = null;
			// 01/07/2006   Show table borders in layout mode. This will help distinguish blank lines from wrapped lines. 
			if ( bLayoutMode )
				tbl.Border = 1;
			// 11/15/2007   If there are no fields in the detail view, then hide the entire table. 
			// This allows us to hide the table by removing all detail view fields. 
			// 09/12/2009   There is no reason to hide the table when in layout mode. 
			if ( dvFields.Count == 0 && tbl.Rows.Count <= 1 && !bLayoutMode )
				tbl.Visible = false;

			// 01/27/2008   We need the schema table to determine if the data label is free-form text. 
			// 03/21/2008   We need to use a view to search for the rows for the ColumnName. 
			// 01/18/2010   To apply ACL Field Security, we need to know if the current record has an ASSIGNED_USER_ID field, and its value. 
			Guid gASSIGNED_USER_ID = Guid.Empty;
			//DataView vwSchema = null;
			if ( rdr != null )
			{
				// 11/22/2010   Convert data reader to data table for Rules Wizard. 
				//vwSchema = new DataView(rdr.GetSchemaTable());
				//vwSchema.RowFilter = "ColumnName = 'ASSIGNED_USER_ID'";
				//if ( vwSchema.Count > 0 )
				if ( rdr.Table.Columns.Contains("ASSIGNED_USER_ID") )
				{
					gASSIGNED_USER_ID = Sql.ToGuid(rdr["ASSIGNED_USER_ID"]);
				}
			}

			// 01/01/2008   Pull config flag outside the loop. 
			bool bEnableTeamManagement  = Crm.Config.enable_team_management();
			bool bRequireTeamManagement = Crm.Config.require_team_management();
			// 01/01/2008   We need a quick way to require user assignments across the system. 
			bool bRequireUserAssignment = Crm.Config.require_user_assignment();
			// 08/28/2009   Allow dynamic teams to be turned off. 
			bool bEnableDynamicTeams   = Crm.Config.enable_dynamic_teams();
			HttpSessionState Session = HttpContext.Current.Session;
			HttpApplicationState Application = HttpContext.Current.Application;
			// 10/07/2010   Convert the currency values before displaying. 
			// The UI culture should already be set to format the currency. 
			Currency C10n = HttpContext.Current.Items["C10n"] as Currency;
			// 05/08/2010   Define the copy buttons outside the loop so that we can replace the javascript with embedded code. 
			// This is so that the javascript will run properly in the SixToolbar UpdatePanel. 
			HtmlInputButton btnCopyRight = null;
			HtmlInputButton btnCopyLeft  = null;
			// 09/13/2010   We need to prevent duplicate names. 
			Hashtable hashLABEL_IDs = new Hashtable();
			bool bSupportsDraggable = Sql.ToBoolean(Session["SupportsDraggable"]);
			// 12/13/2013   Allow each line item to have a separate tax rate. 
			bool bEnableTaxLineItems = Sql.ToBoolean(HttpContext.Current.Application["CONFIG.Orders.TaxLineItems"]);
			foreach(DataRowView row in dvFields)
			{
				string sEDIT_NAME         = Sql.ToString (row["EDIT_NAME"        ]);
				int    nFIELD_INDEX       = Sql.ToInteger(row["FIELD_INDEX"      ]);
				string sFIELD_TYPE        = Sql.ToString (row["FIELD_TYPE"       ]);
				string sDATA_LABEL        = Sql.ToString (row["DATA_LABEL"       ]);
				string sDATA_FIELD        = Sql.ToString (row["DATA_FIELD"       ]);
				// 01/19/2010   We need to be able to format a Float field to prevent too many decimal places. 
				string sDATA_FORMAT       = Sql.ToString (row["DATA_FORMAT"      ]);
				string sDISPLAY_FIELD     = Sql.ToString (row["DISPLAY_FIELD"    ]);
				string sCACHE_NAME        = Sql.ToString (row["CACHE_NAME"       ]);
				bool   bDATA_REQUIRED     = Sql.ToBoolean(row["DATA_REQUIRED"    ]);
				bool   bUI_REQUIRED       = Sql.ToBoolean(row["UI_REQUIRED"      ]);
				string sONCLICK_SCRIPT    = Sql.ToString (row["ONCLICK_SCRIPT"   ]);
				string sFORMAT_SCRIPT     = Sql.ToString (row["FORMAT_SCRIPT"    ]);
				short  nFORMAT_TAB_INDEX  = Sql.ToShort  (row["FORMAT_TAB_INDEX" ]);
				int    nFORMAT_MAX_LENGTH = Sql.ToInteger(row["FORMAT_MAX_LENGTH"]);
				int    nFORMAT_SIZE       = Sql.ToInteger(row["FORMAT_SIZE"      ]);
				// 11/02/2010   We need a way to insert NONE into the a ListBox while still allowing multiple rows. 
				// The trick will be to use a negative number.  Use an absolute value here to reduce the areas to fix. 
				int    nFORMAT_ROWS       = Math.Abs(Sql.ToInteger(row["FORMAT_ROWS"]));
				int    nFORMAT_COLUMNS    = Sql.ToInteger(row["FORMAT_COLUMNS"   ]);
				int    nCOLSPAN           = Sql.ToInteger(row["COLSPAN"          ]);
				int    nROWSPAN           = Sql.ToInteger(row["ROWSPAN"          ]);
				string sLABEL_WIDTH       = Sql.ToString (row["LABEL_WIDTH"      ]);
				string sFIELD_WIDTH       = Sql.ToString (row["FIELD_WIDTH"      ]);
				int    nDATA_COLUMNS      = Sql.ToInteger(row["DATA_COLUMNS"     ]);
				// 05/17/2009   Add support for a generic module popup. 
				string sMODULE_TYPE       = String.Empty;
				try
				{
					sMODULE_TYPE = Sql.ToString (row["MODULE_TYPE"]);
				}
				catch(Exception ex)
				{
					// 05/17/2009   The MODULE_TYPE is not in the view, then log the error and continue. 
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}
				// 09/13/2010   Add relationship fields. 
				bool   bVALID_RELATED                = false;
				string sRELATED_SOURCE_MODULE_NAME   = String.Empty;
				string sRELATED_SOURCE_VIEW_NAME     = String.Empty;
				string sRELATED_SOURCE_ID_FIELD      = String.Empty;
				string sRELATED_SOURCE_NAME_FIELD    = String.Empty;
				string sRELATED_VIEW_NAME            = String.Empty;
				string sRELATED_ID_FIELD             = String.Empty;
				string sRELATED_NAME_FIELD           = String.Empty;
				string sRELATED_JOIN_FIELD           = String.Empty;
				try
				{
					sRELATED_SOURCE_MODULE_NAME   = Sql.ToString (row["RELATED_SOURCE_MODULE_NAME"  ]);
					sRELATED_SOURCE_VIEW_NAME     = Sql.ToString (row["RELATED_SOURCE_VIEW_NAME"    ]);
					sRELATED_SOURCE_ID_FIELD      = Sql.ToString (row["RELATED_SOURCE_ID_FIELD"     ]);
					sRELATED_SOURCE_NAME_FIELD    = Sql.ToString (row["RELATED_SOURCE_NAME_FIELD"   ]);
					sRELATED_VIEW_NAME            = Sql.ToString (row["RELATED_VIEW_NAME"           ]);
					sRELATED_ID_FIELD             = Sql.ToString (row["RELATED_ID_FIELD"            ]);
					sRELATED_NAME_FIELD           = Sql.ToString (row["RELATED_NAME_FIELD"          ]);
					sRELATED_JOIN_FIELD           = Sql.ToString (row["RELATED_JOIN_FIELD"          ]);
					bVALID_RELATED =  !Sql.IsEmptyString(sRELATED_SOURCE_VIEW_NAME) && !Sql.IsEmptyString(sRELATED_SOURCE_ID_FIELD) && !Sql.IsEmptyString(sRELATED_SOURCE_NAME_FIELD) 
					               && !Sql.IsEmptyString(sRELATED_VIEW_NAME       ) && !Sql.IsEmptyString(sRELATED_ID_FIELD       ) && !Sql.IsEmptyString(sRELATED_NAME_FIELD       ) 
					               && !Sql.IsEmptyString(sRELATED_JOIN_FIELD      );
				}
				catch(Exception ex)
				{
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}
				// 10/09/2010   Add PARENT_FIELD so that we can establish dependent listboxes. 
				string sPARENT_FIELD = String.Empty;
				try
				{
					sPARENT_FIELD = Sql.ToString (row["PARENT_FIELD"]);
				}
				catch(Exception ex)
				{
					// 05/17/2009   The PARENT_FIELD is not in the view, then log the error and continue. 
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}

				// 04/02/2008   Add support for Regular Expression validation. 
				string sFIELD_VALIDATOR_MESSAGE = Sql.ToString (row["FIELD_VALIDATOR_MESSAGE"]);
				string sVALIDATION_TYPE         = Sql.ToString (row["VALIDATION_TYPE"        ]);
				string sREGULAR_EXPRESSION      = Sql.ToString (row["REGULAR_EXPRESSION"     ]);
				string sDATA_TYPE               = Sql.ToString (row["DATA_TYPE"              ]);
				string sMININUM_VALUE           = Sql.ToString (row["MININUM_VALUE"          ]);
				string sMAXIMUM_VALUE           = Sql.ToString (row["MAXIMUM_VALUE"          ]);
				string sCOMPARE_OPERATOR        = Sql.ToString (row["COMPARE_OPERATOR"       ]);
				// 06/12/2009   Add TOOL_TIP for help hover.
				string sTOOL_TIP                = String.Empty;
				try
				{
					sTOOL_TIP = Sql.ToString (row["TOOL_TIP"]);
				}
				catch(Exception ex)
				{
					// 06/12/2009   The TOOL_TIP is not in the view, then log the error and continue. 
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}
				
				// 12/02/2007   Each view can now have its own number of data columns. 
				// This was needed so that search forms can have 4 data columns. The default is 2 columns. 
				if ( nDATA_COLUMNS == 0 )
					nDATA_COLUMNS = 2;

				// 01/18/2010   To apply ACL Field Security, we need to know if the Module Name, which we will extract from the EditView Name. 
				string sMODULE_NAME = String.Empty;
				string[] arrEDIT_NAME = sEDIT_NAME.Split('.');
				if ( arrEDIT_NAME.Length > 0 )
					sMODULE_NAME = arrEDIT_NAME[0];
				bool bIsReadable  = true;
				bool bIsWriteable = true;
				if ( SplendidInit.bEnableACLFieldSecurity )
				{
					Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, gASSIGNED_USER_ID);
					bIsReadable  = acl.IsReadable();
					// 02/16/2011   We should allow a Read-Only field to be searchable, so always allow writing if the name contains Search. 
					bIsWriteable = acl.IsWriteable() || sEDIT_NAME.Contains(".Search");
				}

				// 11/25/2006   If Team Management has been disabled, then convert the field to a blank. 
				// Keep the field, but treat it as blank so that field indexes will still be valid. 
				// 12/03/2006   Allow the team field to be visible during layout. 
				if ( !bLayoutMode && (sDATA_FIELD == "TEAM_ID" || sDATA_FIELD == "TEAM_SET_NAME") )
				{
					if ( !bEnableTeamManagement )
					{
						sFIELD_TYPE = "Blank";
						bUI_REQUIRED = false;
					}
					else
					{
						// 08/28/2012   DATA_FORMAT for TEAM_ID is 1 when we want to force ModulePopup. 
						if ( bEnableDynamicTeams && sDATA_FORMAT != "1" )
						{
							// 08/31/2009   Don't convert to TeamSelect inside a Search view or Popup view. 
							if ( sEDIT_NAME.IndexOf(".Search") < 0 && sEDIT_NAME.IndexOf(".Popup") < 0 )
							{
								sDATA_LABEL     = ".LBL_TEAM_SET_NAME";
								sDATA_FIELD     = "TEAM_SET_NAME";
								sFIELD_TYPE     = "TeamSelect";
								sONCLICK_SCRIPT = String.Empty;
							}
						}
						else
						{
							// 04/18/2010   If the user manually adds a TeamSelect, we need to convert to a ModulePopup. 
							if ( sFIELD_TYPE == "TeamSelect" )
							{
								sDATA_LABEL     = "Teams.LBL_TEAM";
								sDATA_FIELD     = "TEAM_ID";
								sDISPLAY_FIELD  = "TEAM_NAME";
								sFIELD_TYPE     = "ModulePopup";
								sMODULE_TYPE    = "Teams";
								sONCLICK_SCRIPT = String.Empty;
							}
						}
						// 11/25/2006   Override the required flag with the system value. 
						// 01/01/2008   If Team Management is not required, then let the admin decide. 
						if ( bRequireTeamManagement )
							bUI_REQUIRED = true;
					}
				}
				// 12/13/2013   Allow each product to have a default tax rate. 
				if ( !bLayoutMode && sDATA_FIELD == "TAX_CLASS" )
				{
					if ( bEnableTaxLineItems )
					{
						// 08/28/2009   If dynamic teams are enabled, then always use the set name. 
						sDATA_LABEL = "ProductTemplates.LBL_TAXRATE_ID";
						sDATA_FIELD = "TAXRATE_ID";
						sCACHE_NAME = "TaxRates";
					}
				}
				// 04/04/2010   Hide the Exchange Folder field if disabled for this module or user. 
				if ( !bLayoutMode && sDATA_FIELD == "EXCHANGE_FOLDER" )
				{
					if ( !Crm.Modules.ExchangeFolders(sMODULE_NAME) || !Security.HasExchangeAlias() )
					{
						sFIELD_TYPE = "Blank";
					}
				}
				if ( !bLayoutMode && sDATA_FIELD == "ASSIGNED_USER_ID" )
				{
					// 01/01/2008   We need a quick way to require user assignments across the system. 
					if ( bRequireUserAssignment )
						bUI_REQUIRED = true;
				}
				if ( bIsMobile && String.Compare(sFIELD_TYPE, "AddressButtons", true) == 0 )
				{
					// 11/17/2007   Skip the address buttons on a mobile device. 
					continue;
				}
				// 01/18/2010   Clear the Required flag if the field is not writeable. 
				// Clearing at this stage will apply it to all edit types. 
				if ( bUI_REQUIRED && !bIsWriteable )
					bUI_REQUIRED = false;
				// 09/02/2012   A separator will create a new table. We need to match the outer and inner layout. 
				if ( String.Compare(sFIELD_TYPE, "Separator", true) == 0 )
				{
					if ( tbl.Parent.Parent.Parent is System.Web.UI.WebControls.Table )
					{
						System.Web.UI.WebControls.Table tblOuter = new System.Web.UI.WebControls.Table();
						tblOuter.SkinID = "tabForm";
						tblOuter.Style.Add(HtmlTextWriterStyle.MarginTop, "5px");
						// 09/27/2012   Separator can have an ID and can have a style so that it can be hidden. 
						if ( !Sql.IsEmptyString(sDATA_FIELD) )
							tblOuter.ID = sDATA_FIELD;
						if ( !Sql.IsEmptyString(sDATA_FORMAT) && !bLayoutMode )
							tblOuter.Style.Add(HtmlTextWriterStyle.Display, sDATA_FORMAT);
						int nParentIndex = tbl.Parent.Parent.Parent.Parent.Controls.IndexOf(tbl.Parent.Parent.Parent);
						tbl.Parent.Parent.Parent.Parent.Controls.AddAt(nParentIndex + 1, tblOuter);
						System.Web.UI.WebControls.TableRow trOuter = new System.Web.UI.WebControls.TableRow();
						tblOuter.Rows.Add(trOuter);
						System.Web.UI.WebControls.TableCell tdOuter = new System.Web.UI.WebControls.TableCell();
						trOuter.Cells.Add(tdOuter);
						System.Web.UI.HtmlControls.HtmlTable tblInner = new System.Web.UI.HtmlControls.HtmlTable();
						tblInner.Attributes.Add("class", "tabEditView");
						tdOuter.Controls.Add(tblInner);
						tbl = tblInner;
					
						nRowIndex = -1;
						nColIndex = 0;
						tdLabel = null;
						tdField = null;
						if ( bLayoutMode )
							tbl.Border = 1;
						else
							continue;
					}
				}
				// 11/17/2007   On a mobile device, each new field is on a new row. 
				// 12/02/2005  COLSPAN == -1 means that a new column should not be created. 
				if ( (nCOLSPAN >= 0 && nColIndex == 0) || tr == null || bIsMobile )
				{
					// 11/25/2005   Don't pre-create a row as we don't want a blank
					// row at the bottom.  Add rows just before they are needed. 
					nRowIndex++;
					tr = new HtmlTableRow();
					tbl.Rows.Insert(nRowIndex, tr);
				}
				if ( bLayoutMode )
				{
					HtmlTableCell tdAction = new HtmlTableCell();
					tr.Cells.Add(tdAction);
					tdAction.Attributes.Add("class", "tabDetailViewDL");
					tdAction.NoWrap = true;

					Literal litIndex = new Literal();
					tdAction.Controls.Add(litIndex);
					litIndex.Text = " " + nFIELD_INDEX.ToString() + " ";

					// 05/26/2007   Fix the terms. The are in the Dropdown module. 
					// 08/24/2009   Since this is the only area where we use the ID of the dynamic view record, only get it here. 
					Guid gID = Sql.ToGuid(row["ID"]);
					// 05/18/2013   Add drag handle. 
					if ( bSupportsDraggable )
					{
						Image imgDragIcon = new Image();
						imgDragIcon.SkinID = "draghandle_table";
						imgDragIcon.Attributes.Add("draggable"  , "true");
						imgDragIcon.Attributes.Add("ondragstart", "event.dataTransfer.setData('Text', '" + nFIELD_INDEX.ToString() + "');");
						tdAction.Controls.Add(imgDragIcon);
		
						tdAction.Attributes.Add("ondragover", "LayoutDragOver(event, '" + nFIELD_INDEX.ToString() + "')");
						tdAction.Attributes.Add("ondrop"    , "LayoutDropIndex(event, '" + nFIELD_INDEX.ToString() + "')");
					}
					else
					{
						ImageButton btnMoveUp   = CreateLayoutImageButtonSkin(gID, "Layout.MoveUp"  , nFIELD_INDEX, L10n.Term("Dropdown.LNK_UP"    ), "uparrow_inline"  , Page_Command);
						ImageButton btnMoveDown = CreateLayoutImageButtonSkin(gID, "Layout.MoveDown", nFIELD_INDEX, L10n.Term("Dropdown.LNK_DOWN"  ), "downarrow_inline", Page_Command);
						tdAction.Controls.Add(btnMoveUp  );
						tdAction.Controls.Add(btnMoveDown);
					}
					ImageButton btnInsert   = CreateLayoutImageButtonSkin(gID, "Layout.Insert"  , nFIELD_INDEX, L10n.Term("Dropdown.LNK_INS"   ), "plus_inline"     , Page_Command);
					ImageButton btnEdit     = CreateLayoutImageButtonSkin(gID, "Layout.Edit"    , nFIELD_INDEX, L10n.Term("Dropdown.LNK_EDIT"  ), "edit_inline"     , Page_Command);
					ImageButton btnDelete   = CreateLayoutImageButtonSkin(gID, "Layout.Delete"  , nFIELD_INDEX, L10n.Term("Dropdown.LNK_DELETE"), "delete_inline"   , Page_Command);
					tdAction.Controls.Add(btnInsert  );
					tdAction.Controls.Add(btnEdit    );
					tdAction.Controls.Add(btnDelete  );
				}
				// 12/03/2006   Move literal label up so that it can be accessed when processing a blank. 
				Literal litLabel = new Literal();
				if ( !Sql.IsEmptyString(sDATA_FIELD) && !hashLABEL_IDs.Contains(sDATA_FIELD) )
				{
					litLabel.ID = sDATA_FIELD + "_LABEL";
					hashLABEL_IDs.Add(sDATA_FIELD, null);
				}
				// 06/20/2009   The label and the field will be on separate rows for a NewRecord form. 
				HtmlTableRow trLabel = tr;
				HtmlTableRow trField = tr;
				if ( nCOLSPAN >= 0 || tdLabel == null || tdField == null )
				{
					tdLabel = new HtmlTableCell();
					tdField = new HtmlTableCell();
					trLabel.Cells.Add(tdLabel);
					if ( sLABEL_WIDTH == "100%" && sFIELD_WIDTH == "0%" && nDATA_COLUMNS == 1 )
					{
						nRowIndex++;
						trField = new HtmlTableRow();
						tbl.Rows.Insert(nRowIndex, trField);
					}
					else
					{
						// 06/20/2009   Don't specify the normal styles for a NewRecord form. 
						// This is so that the label will be left aligned. 
						tdLabel.Attributes.Add("class", "dataLabel");
						tdLabel.VAlign = "top";
						tdLabel.Width  = sLABEL_WIDTH;
						tdField.Attributes.Add("class", "dataField");
						tdField.VAlign = "top";
					}
					trField.Cells.Add(tdField);
					if ( nCOLSPAN > 0 )
					{
						tdField.ColSpan = nCOLSPAN;
						if ( bLayoutMode )
							tdField.ColSpan++;
					}
					// 11/28/2005   Don't use the field width if COLSPAN is specified as we want it to take the rest of the table.  The label width will be sufficient. 
					if ( nCOLSPAN == 0 && sFIELD_WIDTH != "0%" )
						tdField.Width  = sFIELD_WIDTH;

					tdLabel.Controls.Add(litLabel);
					// 01/18/2010   Apply ACL Field Security. 
					litLabel.Visible = bLayoutMode || bIsReadable;
					//litLabel.Text = nFIELD_INDEX.ToString() + " (" + nRowIndex.ToString() + "," + nColIndex.ToString() + ")";
					try
					{
						// 12/03/2006   Move code to blank able in layout mode to blank section below. 
						if ( bLayoutMode )
							litLabel.Text = sDATA_LABEL;
						else if ( sDATA_LABEL.IndexOf(".") >= 0 )
							litLabel.Text = L10n.Term(sDATA_LABEL);
						else if ( !Sql.IsEmptyString(sDATA_LABEL) && rdr != null )
						{
							// 01/27/2008   If the data label is not in the schema table, then it must be free-form text. 
							// It is not used often, but we allow the label to come from the result set.  For example,
							// when the parent is stored in the record, we need to pull the module name from the record. 
							litLabel.Text = sDATA_LABEL;
							// 11/22/2010   Convert data reader to data table for Rules Wizard. 
							if ( rdr != null )
							{
								//vwSchema.RowFilter = "ColumnName = '" + Sql.EscapeSQL(sDATA_LABEL) + "'";
								//if ( vwSchema.Count > 0 )
								if ( rdr.Table.Columns.Contains(sDATA_LABEL) )
									litLabel.Text = Sql.ToString(rdr[sDATA_LABEL]) + L10n.Term("Calls.LBL_COLON");
							}
						}
						// 07/15/2006   Always put something for the label so that table borders will look right. 
						// 07/20/2007 Vandalo.  Skip the requirement to create a terminology entry and just so the label. 
						else
							litLabel.Text = sDATA_LABEL;  // "&nbsp;";

						// 06/12/2009   Add Tool Tip hover. 
						// 11/23/2009   Only add tool tip if AJAX is available and this is not a mobile device. 
						// 01/18/2010   Only add tool tip if the label is visible. 
						if ( !bIsMobile && mgrAjax != null && !Sql.IsEmptyString(sTOOL_TIP) && !Sql.IsEmptyString(sDATA_FIELD) && litLabel.Visible )
						{
							Image imgToolTip = new Image();
							imgToolTip.SkinID = "tooltip_inline";
							imgToolTip.ID     = sDATA_FIELD + "_TOOLTIP_IMAGE";
							tdLabel.Controls.Add(imgToolTip);
							
							Panel pnlToolTip = new Panel();
							pnlToolTip.ID       = sDATA_FIELD + "_TOOLTIP_PANEL";
							pnlToolTip.CssClass = "tooltip";
							tdLabel.Controls.Add(pnlToolTip);

							Literal litToolTip = new Literal();
							litToolTip.Text = sDATA_FIELD;
							pnlToolTip.Controls.Add(litToolTip);
							if ( bLayoutMode )
								litToolTip.Text = sTOOL_TIP;
							else if ( sTOOL_TIP.IndexOf(".") >= 0 )
								litToolTip.Text = L10n.Term(sTOOL_TIP);
							else
								litToolTip.Text = sTOOL_TIP;
							
							AjaxControlToolkit.HoverMenuExtender hovToolTip = new AjaxControlToolkit.HoverMenuExtender();
							hovToolTip.TargetControlID = imgToolTip.ID;
							hovToolTip.PopupControlID  = pnlToolTip.ID;
							hovToolTip.PopupPosition   = AjaxControlToolkit.HoverMenuPopupPosition.Right;
							hovToolTip.PopDelay        = 50;
							hovToolTip.OffsetX         = 0;
							hovToolTip.OffsetY         = 0;
							tdLabel.Controls.Add(hovToolTip);
						}
					}
					catch(Exception ex)
					{
						SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						litLabel.Text = ex.Message;
					}
					if ( !bLayoutMode && bUI_REQUIRED )
					{
						Label lblRequired = new Label();
						tdLabel.Controls.Add(lblRequired);
						lblRequired.CssClass = "required";
						lblRequired.Text = L10n.Term(".LBL_REQUIRED_SYMBOL");
					}
				}
				
				if ( String.Compare(sFIELD_TYPE, "Blank", true) == 0 )
				{
					// 06/20/2009   There is no need for blank fields in a NewRecord form. 
					// By hiding them we are able to properly disable Team selection when Team Mangement is disabled. 
					if ( sLABEL_WIDTH == "100%" && sFIELD_WIDTH == "0%" && nDATA_COLUMNS == 1 )
					{
						trLabel.Visible = false;
						trField.Visible = false;
					}
					else
					{
						Literal litField = new Literal();
						tdField.Controls.Add(litField);
						if ( bLayoutMode )
						{
							litLabel.Text = "*** BLANK ***";
							litField.Text = "*** BLANK ***";
						}
						else
						{
							// 12/03/2006   Make sure to clear the label.  This is necessary to convert a TEAM to blank when disabled. 
							litLabel.Text = "&nbsp;";
							litField.Text = "&nbsp;";
						}
					}
				}
				// 09/03/2012   A separator does nothing in Layout mode. 
				else if ( String.Compare(sFIELD_TYPE, "Separator", true) == 0 )
				{
					if ( bLayoutMode )
					{
						litLabel.Text = "*** SEPARATOR ***";
						nColIndex = nDATA_COLUMNS;
						tdField.ColSpan = 2 * nDATA_COLUMNS - 1;
						// 09/03/2012   When in layout mode, we need to add a column for arrangement. 
						tdField.ColSpan++;
					}
				}
				// 09/02/2012   A header is similar to a label, but without the data field. 
				else if ( String.Compare(sFIELD_TYPE, "Header", true) == 0 )
				{
					if ( !bLayoutMode )
						litLabel.Text = "<h4>" + litLabel.Text + "</h4>";
					tdLabel.ColSpan = 2;
					tdField.Visible = false;
				}
				else if ( String.Compare(sFIELD_TYPE, "Label", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 05/23/2014   Use a label instead of a literal so that the field can be accessed using HTML DOM. 
						Label litField = new Label();
						tdField.Controls.Add(litField);
						// 07/25/2006   Align label values to the middle so the line-up with the label. 
						tdField.VAlign = "middle";
						// 07/24/2006   Set the ID so that the literal control can be accessed. 
						litField.ID = sDATA_FIELD;
						// 01/18/2010   Apply ACL Field Security. 
						// 10/07/2010   We need to apply ACL on each part of the label. 
						//litField.Visible = bLayoutMode || bIsReadable;
						try
						{
							if ( bLayoutMode )
								litField.Text = sDATA_FIELD;
/*
							else if ( sDATA_FIELD.IndexOf(".") >= 0 )
								litField.Text = L10n.Term(sDATA_FIELD);
							else if ( rdr != null )
								litField.Text = Sql.ToString(rdr[sDATA_FIELD]);
*/
							// 10/07/2010   Allow a label to contain multiple data entries. 
							else
							{
								string[] arrDATA_FIELD = sDATA_FIELD.Split(' ');
								object[] objDATA_FIELD = new object[arrDATA_FIELD.Length];
								for ( int i=0 ; i < arrDATA_FIELD.Length; i++ )
								{
									if ( arrDATA_FIELD[i].IndexOf(".") >= 0 )
									{
										objDATA_FIELD[i] = L10n.Term(arrDATA_FIELD[i]);
									}
									else if ( !Sql.IsEmptyString(arrDATA_FIELD[i]) )
									{
										bIsReadable = true;
										if ( SplendidInit.bEnableACLFieldSecurity )
										{
											Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, sDATA_FIELD, gASSIGNED_USER_ID);
											bIsReadable  = acl.IsReadable();
										}
										if ( bIsReadable && rdr != null && rdr[arrDATA_FIELD[i]] != DBNull.Value)
										{
											// 12/05/2005   If the data is a DateTime field, then make sure to perform the timezone conversion. 
											if ( rdr[arrDATA_FIELD[i]].GetType() == Type.GetType("System.DateTime") )
												objDATA_FIELD[i] = T10n.FromServerTime(rdr[arrDATA_FIELD[i]]);
											// 02/16/2010   Add MODULE_TYPE so that we can lookup custom field IDs. 
											// 02/16/2010   Move ToGuid to the function so that it can be captured if invalid. 
											else if ( !Sql.IsEmptyString(sMODULE_TYPE) )
												objDATA_FIELD[i] = Crm.Modules.ItemName(Application, sMODULE_TYPE, rdr[arrDATA_FIELD[i]]);
											else
												objDATA_FIELD[i] = rdr[arrDATA_FIELD[i]];
										}
										else
											objDATA_FIELD[i] = String.Empty;
									}
								}
								// 08/28/2012   We do not need the record to display a label. 
								//if ( rdr != null )
								{
									// 10/07/2010   There is a special case where we are show a date and a user name. 
									if ( arrDATA_FIELD.Length == 3 && objDATA_FIELD.Length == 3 && arrDATA_FIELD[1] == ".LBL_BY" && Sql.IsEmptyString(objDATA_FIELD[0]) && Sql.IsEmptyString(objDATA_FIELD[2]) )
										litField.Text = String.Empty;
									else
									// 01/09/2006   Allow DATA_FORMAT to be optional.   If missing, write data directly. 
									if ( sDATA_FORMAT == String.Empty )
									{
										for ( int i=0; i < arrDATA_FIELD.Length; i++ )
											arrDATA_FIELD[i] = Sql.ToString(objDATA_FIELD[i]);
										litField.Text = String.Join(" ", arrDATA_FIELD);
									}
									else if ( sDATA_FORMAT == "{0:c}" && C10n != null )
									{
										// 03/30/2007   Convert DetailView currencies on the fly. 
										// 05/05/2007   In an earlier step, we convert NULLs to empty strings. 
										// Attempts to convert to decimal will generate an error: Input string was not in a correct format.
										if ( !(objDATA_FIELD[0] is string) )
										{
											Decimal d = C10n.ToCurrency(Convert.ToDecimal(objDATA_FIELD[0]));
											litField.Text = d.ToString("c");
										}
									}
									else
										litField.Text = String.Format(sDATA_FORMAT, objDATA_FIELD);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							litField.Text = ex.Message;
						}
					}
				}
				// 09/13/2010   Add relationship fields. 
				else if ( String.Compare(sFIELD_TYPE, "RelatedSelect", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) && !Sql.IsEmptyString(sRELATED_SOURCE_MODULE_NAME) && bVALID_RELATED )
					{
						RelatedSelect ctlRelatedSelect = tbl.Page.LoadControl("~/_controls/RelatedSelect.ascx") as RelatedSelect;
						tdField.Controls.Add(ctlRelatedSelect);
						// 09/18/2010   Using a "." in the ID caused major AJAX failures that were hard to debug. 
						//ctlRelatedSelect.ID                           = sRELATED_VIEW_NAME + "_" + sRELATED_ID_FIELD;
						// 10/14/2011   We must use sDATA_FIELD as the ID until we can change UpdateCustomFields() to use the related ID. 
						ctlRelatedSelect.ID                           = sDATA_FIELD;
						ctlRelatedSelect.RELATED_SOURCE_MODULE_NAME   = sRELATED_SOURCE_MODULE_NAME  ;
						ctlRelatedSelect.RELATED_SOURCE_VIEW_NAME     = sRELATED_SOURCE_VIEW_NAME    ;
						ctlRelatedSelect.RELATED_SOURCE_ID_FIELD      = sRELATED_SOURCE_ID_FIELD     ;
						ctlRelatedSelect.RELATED_SOURCE_NAME_FIELD    = sRELATED_SOURCE_NAME_FIELD   ;
						ctlRelatedSelect.RELATED_VIEW_NAME            = sRELATED_VIEW_NAME           ;
						ctlRelatedSelect.RELATED_ID_FIELD             = sRELATED_ID_FIELD            ;
						ctlRelatedSelect.RELATED_NAME_FIELD           = sRELATED_NAME_FIELD          ;
						ctlRelatedSelect.RELATED_JOIN_FIELD           = sRELATED_JOIN_FIELD          ;

						ctlRelatedSelect.NotPostBack = bNotPostBack;
						ctlRelatedSelect.Visible  = bLayoutMode || bIsReadable;
						ctlRelatedSelect.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							Guid gPARENT_ID = Guid.Empty;
							if ( rdr != null )
							{
								try
								{
									gPARENT_ID = Sql.ToGuid(rdr[sDATA_FIELD]);
								}
								catch
								{
								}
							}
							ctlRelatedSelect.LoadLineItems(gPARENT_ID);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "RelatedListBox", true) == 0 || String.Compare(sFIELD_TYPE, "RelatedCheckBoxList", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) && bVALID_RELATED )
					{
						ListControl lstField = new RadioButtonList();
						if ( String.Compare(sFIELD_TYPE, "RelatedListBox", true) == 0 )
						{
							lstField = new ListBox();
							(lstField as ListBox).SelectionMode = ListSelectionMode.Multiple;
							(lstField as ListBox).Rows          = (nFORMAT_ROWS == 0) ? 6 : nFORMAT_ROWS;
							tdField.Controls.Add(lstField);
						}
						else if ( String.Compare(sFIELD_TYPE, "RelatedCheckBoxList", true) == 0 )
						{
							lstField = new CheckBoxList();
							lstField.CssClass = "checkbox";
							// 09/16/2010   Put inside a div so that we can use auto-scroll. 
							if ( nFORMAT_ROWS > 0 )
							{
								HtmlGenericControl div = new HtmlGenericControl("div");
								div.Controls.Add(lstField);
								tdField.Controls.Add(div);
								div.Attributes.Add("style", "overflow-y: auto;height: " + nFORMAT_ROWS.ToString() + "px");
							}
							else
							{
								tdField.Controls.Add(lstField);
							}
						}
						else
						{
							lstField.CssClass = "radio";
							// 09/16/2010   Put inside a div so that we can use auto-scroll. 
							if ( nFORMAT_ROWS > 0 )
							{
								HtmlGenericControl div = new HtmlGenericControl("div");
								div.Controls.Add(lstField);
								tdField.Controls.Add(div);
								div.Attributes.Add("style", "overflow-y: auto;height: " + nFORMAT_ROWS.ToString() + "px");
							}
							else
							{
								tdField.Controls.Add(lstField);
							}
						}
						// 09/13/2010   We should not use the sDATA_FIELD as it might be identical for multiple RelatedListBox.  For example, it could be the ID of the record. 
						// 09/18/2010   Using a "." in the ID caused major AJAX failures that were hard to debug. 
						//lstField.ID            = sRELATED_VIEW_NAME + "_" + sRELATED_ID_FIELD;// sDATA_FIELD;
						// 10/14/2011   We must use sDATA_FIELD as the ID until we can change UpdateCustomFields() to use the related ID. 
						lstField.ID            = sDATA_FIELD;
						lstField.TabIndex      = nFORMAT_TAB_INDEX;
						lstField.Visible       = bLayoutMode || bIsReadable;
						lstField.Enabled       = bLayoutMode || bIsWriteable;
						try
						{
							// 09/13/2010   As extra precaution, make sure that the table name is valid. 
							Regex r = new Regex(@"[^A-Za-z0-9_]");
							sRELATED_SOURCE_VIEW_NAME     = r.Replace(sRELATED_SOURCE_VIEW_NAME    , "");
							sRELATED_SOURCE_ID_FIELD      = r.Replace(sRELATED_SOURCE_ID_FIELD     , "");
							sRELATED_SOURCE_NAME_FIELD    = r.Replace(sRELATED_SOURCE_NAME_FIELD   , "");
							sRELATED_VIEW_NAME            = r.Replace(sRELATED_VIEW_NAME           , "");
							sRELATED_ID_FIELD             = r.Replace(sRELATED_ID_FIELD            , "");
							sRELATED_NAME_FIELD           = r.Replace(sRELATED_NAME_FIELD          , "");
							sRELATED_JOIN_FIELD           = r.Replace(sRELATED_JOIN_FIELD          , "");

							// 09/13/2010   Add relationship fields, Don't populate list if this is a post back. 
							if ( (bLayoutMode || !bIsPostBack) )
							{
								lstField.DataValueField = sRELATED_SOURCE_ID_FIELD  ;
								lstField.DataTextField  = sRELATED_SOURCE_NAME_FIELD;
								DbProviderFactory dbf = DbProviderFactories.GetFactory();
								using ( IDbConnection con = dbf.CreateConnection() )
								{
									con.Open();
									string sSQL;
									sSQL = "select " + sRELATED_SOURCE_ID_FIELD      + ControlChars.CrLf
									     + "     , " + sRELATED_SOURCE_NAME_FIELD    + ControlChars.CrLf
									     + "  from " + sRELATED_SOURCE_VIEW_NAME     + ControlChars.CrLf
									     + " order by " + sRELATED_SOURCE_NAME_FIELD + ControlChars.CrLf;
									using ( IDbCommand cmd = con.CreateCommand() )
									{
										cmd.CommandText = sSQL;
										// 09/13/2010   When in layout mode, only fetch 10 records. 
										if ( bLayoutMode )
											Sql.LimitResults(cmd, 10);
										using ( DbDataAdapter da = dbf.CreateDataAdapter() )
										{
											((IDbDataAdapter)da).SelectCommand = cmd;
											DataTable dt = new DataTable();
											da.Fill(dt);
											lstField.DataSource = dt;
											lstField.DataBind();
										}
									}
								}
								if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
									lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
								// 10/02/2010   None does not seem appropriate for related data. 
								/*
								if ( !bUI_REQUIRED )
								{
									lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
									lstField.DataBound += new EventHandler(ListControl_DataBound_AllowNull);
								}
								*/
							}
							if ( rdr != null )
							{
								try
								{
									// 10/14/2011   When settings values, there does not seem to be a good reason to do another database lookup. 
									// The lstField binding means that the values are there. 
									if ( rdr[sDATA_FIELD].GetType() == typeof(Guid) )
									{
										string sVALUE = Sql.ToGuid(rdr[sDATA_FIELD]).ToString();
										foreach ( ListItem item in lstField.Items )
										{
											if ( item.Value == sVALUE )
												item.Selected = true;
										}
									}
									else
									{
										List<string> arrVALUE = new List<string>();
										// 10/14/2011   If this is a multi-selection, then we need to get the list if values. 
										string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
										if ( sVALUE.StartsWith("<?xml") )
										{
											XmlDocument xml = new XmlDocument();
											xml.LoadXml(sVALUE);
											XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
											foreach ( XmlNode xValue in nlValues )
											{
												foreach ( ListItem item in lstField.Items )
												{
													if ( item.Value == xValue.InnerText )
														item.Selected = true;
												}
											}
										}
										else
										{
											foreach ( ListItem item in lstField.Items )
											{
												if ( item.Value == sVALUE )
													item.Selected = true;
											}
										}
									}
								}
								catch(Exception ex)
								{
									SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
								}
							}
							// 12/04/2005   Assigned To field will always default to the current user. 
							else if ( rdr == null && !bIsPostBack && sCACHE_NAME == "AssignedUser")
							{
								try
								{
									// 12/02/2007   We don't default the user when using multi-selection.  
									// This is because this mode is typically used for searching. 
									if ( nFORMAT_ROWS == 0 )
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetValue(lstField, Security.USER_ID.ToString());
								}
								catch(Exception ex)
								{
									SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "ListBox", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/02/2007   If format rows > 0 then this is a list box and not a drop down list. 
						ListControl lstField = null;
						if ( nFORMAT_ROWS > 0 )
						{
							ListBox lb = new ListBox();
							lb.SelectionMode = ListSelectionMode.Multiple;
							lb.Rows          = nFORMAT_ROWS;
							lstField = lb;
						}
						else
						{
							// 04/25/2008   Use KeySortDropDownList instead of ListSearchExtender. 
							lstField = new KeySortDropDownList();
							// 07/26/2010   Lets try the latest version of the ListSearchExtender. 
							// 07/28/2010   We are getting an undefined exception on the Accounts List Advanced page. 
							// Lets drop back to using KeySort. 
							//lstField = new DropDownList();
						}
						tdField.Controls.Add(lstField);
						lstField.ID       = sDATA_FIELD;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						lstField.Visible  = bLayoutMode || bIsReadable;
						lstField.Enabled  = bLayoutMode || bIsWriteable;

						try
						{
							// 10/09/2010   Add PARENT_FIELD so that we can establish dependent listboxes. 
							if ( !Sql.IsEmptyString(sPARENT_FIELD) )
							{
								ListControl lstPARENT_FIELD = tbl.FindControl(sPARENT_FIELD) as ListControl;
								if ( lstPARENT_FIELD != null )
								{
									lstPARENT_FIELD.AutoPostBack = true;
									// 11/02/2010   We need a way to insert NONE into the a ListBox while still allowing multiple rows. 
									// The trick will be to use a negative number.  Use an absolute value here to reduce the areas to fix. 
									EditViewEventManager mgr = new EditViewEventManager(lstPARENT_FIELD, lstField, bUI_REQUIRED, Sql.ToInteger(row["FORMAT_ROWS"]), L10n);
									lstPARENT_FIELD.SelectedIndexChanged += new EventHandler(mgr.SelectedIndexChanged);
									if ( !bIsPostBack && lstPARENT_FIELD.SelectedIndex >= 0 )
									{
										sCACHE_NAME = lstPARENT_FIELD.SelectedValue;
									}
								}
							}
							// 12/04/2005   Don't populate list if this is a post back. 
							if ( !Sql.IsEmptyString(sCACHE_NAME) && (bLayoutMode || !bIsPostBack) )
							{
								// 12/24/2007   Use an array to define the custom caches so that list is in the Cache module. 
								// This should reduce the number of times that we have to edit the SplendidDynamic module. 
								// 02/16/2012   Move custom cache logic to a method. 
								SplendidCache.SetListSource(sCACHE_NAME, lstField);
								lstField.DataBind();
								// 08/08/2006   Allow onchange code to be stored in the database.  
								// ListBoxes do not have a useful onclick event, so there should be no problem overloading this field. 
								if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
									lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
								// 02/21/2006   Move the NONE item inside the !IsPostBack code. 
								// 12/02/2007   We don't need a NONE record when using multi-selection. 
								// 12/03/2007   We do want the NONE record when using multi-selection. 
								// This will allow searching of fields that are null instead of using the unassigned only checkbox. 
								// 10/02/2010   It does not seem logical to allow a NONE option on a multi-selection listbox. 
								// 11/02/2010   We need a way to insert NONE into the a ListBox while still allowing multiple rows. 
								// The trick will be to use a negative number.  Use an absolute value here to reduce the areas to fix. 
								if ( !bUI_REQUIRED && Sql.ToInteger(row["FORMAT_ROWS"]) <= 0 )
								{
                                    lstField.Items.Insert(0, new ListItem("--È«²¿--",""));

                                    /*
									lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
									// 12/02/2007   AppendEditViewFields should be called inside Page_Load when not a postback, 
									// and in InitializeComponent when it is a postback. If done wrong, 
									// the page will bind after the list is populated, causing the list to populate again. 
									// This event will cause the NONE entry to be cleared.  Add a handler to catch this problem, 
									// but the real solution is to call AppendEditViewFields at the appropriate times based on the postback event. 
									lstField.DataBound += new EventHandler(ListControl_DataBound_AllowNull);
                                     */
								}
								// 01/20/2010   Set the default value for Currencies. 
								if ( !bLayoutMode && rdr == null && !bIsPostBack && sCACHE_NAME == "Currencies" )
								{
									try
									{
										Guid gCURRENCY_ID = Sql.ToGuid(HttpContext.Current.Session["USER_SETTINGS/CURRENCY"]);
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetValue(lstField, gCURRENCY_ID.ToString());
									}
									catch
									{
									}
								}
							}
							if ( rdr != null )
							{
								try
								{
									// 02/21/2006   All the DropDownLists in the Calls and Meetings edit views were not getting set.  
									// The problem was a Page.DataBind in the SchedulingGrid and in the InviteesView. Both binds needed to be removed. 
									// 12/30/2007   A customer needed the ability to save and restore the multiple selection. 
									// 12/30/2007   Require the XML declaration in the data before trying to treat as XML. 
									string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
									if ( nFORMAT_ROWS > 0 && sVALUE.StartsWith("<?xml") )
									{
										XmlDocument xml = new XmlDocument();
										xml.LoadXml(sVALUE);
										XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
										foreach ( XmlNode xValue in nlValues )
										{
											foreach ( ListItem item in lstField.Items )
											{
												if ( item.Value == xValue.InnerText )
													item.Selected = true;
											}
										}
									}
									else
									{
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetValue(lstField, sVALUE);
									}
								}
								catch(Exception ex)
								{
									SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
								}
							}
							// 12/04/2005   Assigned To field will always default to the current user. 
							else if ( rdr == null && !bIsPostBack && sCACHE_NAME == "AssignedUser")
							{
								try
								{
									// 12/02/2007   We don't default the user when using multi-selection.  
									// This is because this mode is typically used for searching. 
									if ( nFORMAT_ROWS == 0 )
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetValue(lstField, Security.USER_ID.ToString());
								}
								catch(Exception ex)
								{
									SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				// 06/16/2010   Add support for CheckBoxList. 
				else if ( String.Compare(sFIELD_TYPE, "CheckBoxList", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/02/2007   If format rows > 0 then this is a list box and not a drop down list. 
						ListControl lstField = new CheckBoxList();
						// 09/16/2010   Put inside a div so that we can use auto-scroll. 
						if ( nFORMAT_ROWS > 0 )
						{
							HtmlGenericControl div = new HtmlGenericControl("div");
							div.Controls.Add(lstField);
							tdField.Controls.Add(div);
							div.Attributes.Add("style", "overflow-y: auto;height: " + nFORMAT_ROWS.ToString() + "px");
						}
						else
						{
							tdField.Controls.Add(lstField);
						}
						lstField.ID       = sDATA_FIELD;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						lstField.CssClass = "checkbox";
						// 01/18/2010   Apply ACL Field Security. 
						lstField.Visible  = bLayoutMode || bIsReadable;
						lstField.Enabled  = bLayoutMode || bIsWriteable;
						// 03/22/2013   Allow horizontal CheckBoxList. 
						if ( sDATA_FORMAT == "1" )
						{
							(lstField as CheckBoxList).RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
							(lstField as CheckBoxList).RepeatLayout    = System.Web.UI.WebControls.RepeatLayout.Flow;
						}
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) )
							{
								// 12/04/2005   Don't populate list if this is a post back. 
								if ( !Sql.IsEmptyString(sCACHE_NAME) && (bLayoutMode || !bIsPostBack) )
								{
									// 12/24/2007   Use an array to define the custom caches so that list is in the Cache module. 
									// This should reduce the number of times that we have to edit the SplendidDynamic module. 
									// 02/16/2012   Move custom cache logic to a method. 
									SplendidCache.SetListSource(sCACHE_NAME, lstField);
									lstField.DataBind();
								}
								if ( rdr != null )
								{
									try
									{
										string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
										if ( sVALUE.StartsWith("<?xml") )
										{
											XmlDocument xml = new XmlDocument();
											xml.LoadXml(sVALUE);
											XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
											foreach ( XmlNode xValue in nlValues )
											{
												foreach ( ListItem item in lstField.Items )
												{
													if ( item.Value == xValue.InnerText )
														item.Selected = true;
												}
											}
										}
										// 03/22/2013   REPEAT_DOW is a special list that returns 0 = sunday, 1 = monday, etc. 
										else if ( sDATA_FIELD == "REPEAT_DOW" )
										{
											for ( int i = 0; i < lstField.Items.Count; i++ )
											{
												if ( sVALUE.Contains(i.ToString()) )
													lstField.Items[i].Selected = true;
											}
										}
										else
										{
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetValue(lstField, sVALUE);
										}
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
								// 12/04/2005   Assigned To field will always default to the current user. 
								else if ( rdr == null && !bIsPostBack && sCACHE_NAME == "AssignedUser")
								{
									try
									{
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetValue(lstField, Security.USER_ID.ToString());
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				// 06/16/2010   Add support for Radio buttons. 
				else if ( String.Compare(sFIELD_TYPE, "Radio", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						ListControl lstField = new RadioButtonList();
						// 09/16/2010   Put inside a div so that we can use auto-scroll. 
						if ( nFORMAT_ROWS > 0 )
						{
							HtmlGenericControl div = new HtmlGenericControl("div");
							div.Controls.Add(lstField);
							tdField.Controls.Add(div);
							div.Attributes.Add("style", "overflow-y: auto;height: " + nFORMAT_ROWS.ToString() + "px");
						}
						else
						{
							tdField.Controls.Add(lstField);
						}
						lstField.ID       = sDATA_FIELD;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						lstField.CssClass = "radio";
						// 01/18/2010   Apply ACL Field Security. 
						lstField.Visible  = bLayoutMode || bIsReadable;
						lstField.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( !Sql.IsEmptyString(sDATA_FIELD) )
							{
								// 12/04/2005   Don't populate list if this is a post back. 
								if ( !Sql.IsEmptyString(sCACHE_NAME) && (bLayoutMode || !bIsPostBack) )
								{
									// 12/24/2007   Use an array to define the custom caches so that list is in the Cache module. 
									// This should reduce the number of times that we have to edit the SplendidDynamic module. 
									// 02/16/2012   Move custom cache logic to a method. 
									SplendidCache.SetListSource(sCACHE_NAME, lstField);
									lstField.DataBind();
									// 08/08/2006   Allow onchange code to be stored in the database.  
									// ListBoxes do not have a useful onclick event, so there should be no problem overloading this field. 
									if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
										lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
									// 02/21/2006   Move the NONE item inside the !IsPostBack code. 
									// 12/02/2007   We don't need a NONE record when using multi-selection. 
									// 12/03/2007   We do want the NONE record when using multi-selection. 
									// This will allow searching of fields that are null instead of using the unassigned only checkbox. 
									if ( !bUI_REQUIRED )
									{
										lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
										// 12/02/2007   AppendEditViewFields should be called inside Page_Load when not a postback, 
										// and in InitializeComponent when it is a postback. If done wrong, 
										// the page will bind after the list is populated, causing the list to populate again. 
										// This event will cause the NONE entry to be cleared.  Add a handler to catch this problem, 
										// but the real solution is to call AppendEditViewFields at the appropriate times based on the postback event. 
										lstField.DataBound += new EventHandler(ListControl_DataBound_AllowNull);
									}
									else
									{
										// 06/16/2010   If the UI is required for Radio buttons, then we need to set the first item. 
										if ( !bIsPostBack && rdr == null )
										{
											lstField.SelectedIndex = 0;
										}
									}
									// 01/20/2010   Set the default value for Currencies. 
									if ( !bLayoutMode && rdr == null && !bIsPostBack && sCACHE_NAME == "Currencies" )
									{
										try
										{
											Guid gCURRENCY_ID = Sql.ToGuid(HttpContext.Current.Session["USER_SETTINGS/CURRENCY"]);
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetValue(lstField, gCURRENCY_ID.ToString());
										}
										catch
										{
										}
									}
								}
								if ( rdr != null )
								{
									try
									{
										// 02/21/2006   All the DropDownLists in the Calls and Meetings edit views were not getting set.  
										// The problem was a Page.DataBind in the SchedulingGrid and in the InviteesView. Both binds needed to be removed. 
										// 12/30/2007   A customer needed the ability to save and restore the multiple selection. 
										// 12/30/2007   Require the XML declaration in the data before trying to treat as XML. 
										string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
										if ( nFORMAT_ROWS > 0 && sVALUE.StartsWith("<?xml") )
										{
											XmlDocument xml = new XmlDocument();
											xml.LoadXml(sVALUE);
											XmlNodeList nlValues = xml.DocumentElement.SelectNodes("Value");
											foreach ( XmlNode xValue in nlValues )
											{
												foreach ( ListItem item in lstField.Items )
												{
													if ( item.Value == xValue.InnerText )
														item.Selected = true;
												}
											}
										}
										else
										{
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetValue(lstField, sVALUE);
										}
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
								// 12/04/2005   Assigned To field will always default to the current user. 
								else if ( rdr == null && !bIsPostBack && sCACHE_NAME == "AssignedUser")
								{
									try
									{
										// 12/02/2007   We don't default the user when using multi-selection.  
										// This is because this mode is typically used for searching. 
										if ( nFORMAT_ROWS == 0 )
											// 08/19/2010   Check the list before assigning the value. 
											Utils.SetValue(lstField, Security.USER_ID.ToString());
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "CheckBox", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						CheckBox chkField = new CheckBox();
						tdField.Controls.Add(chkField);
						chkField.ID = sDATA_FIELD;
						chkField.CssClass = "checkbox";
						chkField.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						chkField.Visible  = bLayoutMode || bIsReadable;
						chkField.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( rdr != null )
								chkField.Checked = Sql.ToBoolean(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						// 07/11/2007   A checkbox can have a click event. 
						if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
							chkField.Attributes.Add("onclick", sONCLICK_SCRIPT);
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
							chkField.Enabled  = false     ;
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "ChangeButton", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						//05/06/2010   Manually generate ClearModuleType so that it will be UpdatePanel safe. 
						DropDownList lstField = null;
						// 12/04/2005   If the label is PARENT_TYPE, then change the label to a DropDownList.
						if ( sDATA_LABEL == "PARENT_TYPE" )
						{
							tdLabel.Controls.Clear();
							// 04/25/2008   Use KeySortDropDownList instead of ListSearchExtender. 
							// 01/13/2010   KeySortDropDownList is causing OnChange will always fire when tabbed-away. 
							// For the Parent DropDownList, we don't need the KeySort as it is a short list. 
							//DropDownList lstField = new KeySortDropDownList();
							lstField = new DropDownList();
							tdLabel.Controls.Add(lstField);
							// 11/11/2010   Give the parent type a unique name. 
							// 02/04/2011   We gave the PARENT_TYPE a unique name, but we need to update all EditViews and NewRecords. 
							lstField.ID       = sDATA_FIELD + "_PARENT_TYPE";
							lstField.TabIndex = nFORMAT_TAB_INDEX;
							// 04/02/2013   Apply ACL Field Security to Parent Type field. 
							if ( SplendidInit.bEnableACLFieldSecurity )
							{
								Security.ACL_FIELD_ACCESS acl = Security.GetUserFieldSecurity(sMODULE_NAME, "PARENT_TYPE", gASSIGNED_USER_ID);
								lstField.Visible  = bLayoutMode || acl.IsReadable();
								lstField.Enabled  = bLayoutMode || acl.IsWriteable() || sEDIT_NAME.Contains(".Search");
							}
							
							
							// 04/25/2008   Add AJAX searching of list. 
							// 04/25/2008   ListSearchExtender needs work.  I don't like the delay when a list is selected
							// and there are problems when the browser window is scrolled.  KeySortDropDownList is a better solution. 
							// 07/23/2010   Lets try the latest version of the ListSearchExtender. 
							// 07/28/2010   We are getting an undefined exception on the Accounts List Advanced page. 
							/*
							AjaxControlToolkit.ListSearchExtender extField = new AjaxControlToolkit.ListSearchExtender();
							extField.ID              = lstField.ID + "_ListSearchExtender";
							extField.TargetControlID = lstField.ID;
							extField.PromptText      = L10n.Term(".LBL_TYPE_TO_SEARCH");
							extField.PromptCssClass  = "ListSearchExtenderPrompt";
							tdLabel.Controls.Add(extField);
							*/
							if ( bLayoutMode || !bIsPostBack )
							{
								// 07/29/2005   SugarCRM 3.0 does not allow the NONE option. 
								lstField.DataValueField = "NAME"        ;
								lstField.DataTextField  = "DISPLAY_NAME";
								lstField.DataSource     = SplendidCache.List("record_type_display");
								lstField.DataBind();
								if ( rdr != null )
								{
									try
									{
										// 08/19/2010   Check the list before assigning the value. 
										Utils.SetValue(lstField, Sql.ToString(rdr[sDATA_LABEL]));
									}
									catch(Exception ex)
									{
										SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
									}
								}
							}
						}
						TextBox txtNAME = new TextBox();
						tdField.Controls.Add(txtNAME);
						txtNAME.ID       = sDISPLAY_FIELD;
						txtNAME.ReadOnly = true;
						txtNAME.TabIndex = nFORMAT_TAB_INDEX;
						// 11/25/2006    Turn off viewstate so that we can fix the text on postback. 
						txtNAME.EnableViewState = false;
						// 01/18/2010   Apply ACL Field Security. 
						txtNAME.Visible  = bLayoutMode || bIsReadable;
						txtNAME.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( bLayoutMode )
							{
								txtNAME.Text    = sDISPLAY_FIELD;
								txtNAME.Enabled = false         ;
							}
							// 11/25/2006   The Change text field is losing its value during a postback error. 
							else if ( bIsPostBack )
							{
								// 11/25/2006   In order for this posback fix to work, viewstate must be disabled for this field. 
								if ( tbl.Page.Request[txtNAME.UniqueID] != null )
									txtNAME.Text = Sql.ToString(tbl.Page.Request[txtNAME.UniqueID]);
							}
							else if ( !Sql.IsEmptyString(sDISPLAY_FIELD) && rdr != null )
								txtNAME.Text = Sql.ToString(rdr[sDISPLAY_FIELD]);
							// 11/25/2006   The team name should always default to the current user's private team. 
							// Make sure not to overwrite the value if this is a postback. 
							// 08/26/2009   Don't prepopulate team or user if in a search dialog. 
							else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack )
								txtNAME.Text = Security.TEAM_NAME;
							// 01/15/2007   Assigned To field will always default to the current user. 
							else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
							{
								// 01/29/2011   If Full Names have been enabled, then prepopulate with the full name. 
								if ( sDISPLAY_FIELD == "ASSIGNED_TO_NAME" )
									txtNAME.Text = Security.FULL_NAME;
								else
									txtNAME.Text = Security.USER_NAME;
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						HtmlInputHidden hidID = new HtmlInputHidden();
						tdField.Controls.Add(hidID);
						hidID.ID = sDATA_FIELD;
						try
						{
							if ( !bLayoutMode )
							{
								if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
									hidID.Value = Sql.ToString(rdr[sDATA_FIELD]);
								// 11/25/2006   The team name should always default to the current user's private team. 
								// Make sure not to overwrite the value if this is a postback. 
								// The hidden field does not require the same viewstate fix as the txtNAME field. 
								// 04/23/2009   Make sure not to initialize the field with an empty guid as that will prevent the required field notice. 
								// 08/26/2009   Don't prepopulate team or user if in a search dialog. 
								else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack && !Sql.IsEmptyGuid(Security.TEAM_ID) )
									hidID.Value = Security.TEAM_ID.ToString();
								// 01/15/2007   Assigned To field will always default to the current user. 
								else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
									hidID.Value = Security.USER_ID.ToString();
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						//05/06/2010   Manually generate ClearModuleType so that it will be UpdatePanel safe. 
						// 07/27/2010   Add the ability to submit after clear. 
						if ( sDATA_LABEL == "PARENT_TYPE" && lstField != null )
							lstField.Attributes.Add("onChange", "ClearModuleType('', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', false);");
						
						Literal litNBSP = new Literal();
						tdField.Controls.Add(litNBSP);
						litNBSP.Text = "&nbsp;";
						
						// 06/20/2009   The Select button will go on a separate row in the NewRecord form. 
						if ( sLABEL_WIDTH == "100%" && sFIELD_WIDTH == "0%" && nDATA_COLUMNS == 1 )
						{
							nRowIndex++;
							trField = new HtmlTableRow();
							tbl.Rows.Insert(nRowIndex, trField);
							tdField = new HtmlTableCell();
							trField.Cells.Add(tdField);
						}
						HtmlInputButton btnChange = new HtmlInputButton("button");
						tdField.Controls.Add(btnChange);
						// 05/07/2006   Specify a name for the check button so that it can be referenced by SplendidTest. 
						btnChange.ID = sDATA_FIELD + "_btnChange";
						btnChange.Attributes.Add("class", "button");
						// 05/06/2010   Manually generate ParentPopup so that it will be UpdatePanel safe. 
						// 07/27/2010   Use the DATA_FORMAT field to determine if the ModulePopup will auto-submit. 
						string[] arrDATA_FORMAT = sDATA_FORMAT.Split(',');
						if ( lstField != null )
						{
							btnChange.Attributes.Add("onclick", "return ModulePopup(document.getElementById('" + lstField.ClientID + "').options[document.getElementById('" + lstField.ClientID + "').options.selectedIndex].value, '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', null, " + (arrDATA_FORMAT[0] == "1" ? "true" : "false") + ", null);");
						}
						else if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
							btnChange.Attributes.Add("onclick"  , sONCLICK_SCRIPT);
						// 03/31/2007   SugarCRM now uses Select instead of Change. 
						btnChange.Attributes.Add("title"    , L10n.Term(".LBL_SELECT_BUTTON_TITLE"));
						// 07/31/2006   Stop using VisualBasic library to increase compatibility with Mono. 
						// 03/31/2007   Stop using AccessKey for change button. 
						//btnChange.Attributes.Add("accessKey", L10n.Term(".LBL_SELECT_BUTTON_KEY").Substring(0, 1));
						btnChange.Value = L10n.Term(".LBL_SELECT_BUTTON_LABEL");
						// 01/18/2010   Apply ACL Field Security. 
						btnChange.Visible  =   bLayoutMode || bIsReadable;
						btnChange.Disabled = !(bLayoutMode || bIsWriteable);

						// 12/03/2007   Also create a Clear button. 
						// 05/06/2010   A Parent Type will always have a clear button. 
						if ( sONCLICK_SCRIPT.IndexOf("Popup();") > 0 || sDATA_LABEL == "PARENT_TYPE" )
						{
							litNBSP = new Literal();
							tdField.Controls.Add(litNBSP);
							litNBSP.Text = "&nbsp;";
							
							HtmlInputButton btnClear = new HtmlInputButton("button");
							tdField.Controls.Add(btnClear);
							btnClear.ID = sDATA_FIELD + "_btnClear";
							btnClear.Attributes.Add("class", "button");
							// 05/06/2010   Manually generate ClearModuleType so that it will be UpdatePanel safe. 
							// 07/27/2010   Add the ability to submit after clear. 
							btnClear.Attributes.Add("onclick"  , "return ClearModuleType('', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', " + (arrDATA_FORMAT[0] == "1" ? "true" : "false") + ");");
							btnClear.Attributes.Add("title"    , L10n.Term(".LBL_CLEAR_BUTTON_TITLE"));
							btnClear.Value = L10n.Term(".LBL_CLEAR_BUTTON_LABEL");
							// 01/18/2010   Apply ACL Field Security. 
							btnClear.Visible  =   bLayoutMode || bIsReadable;
							btnClear.Disabled = !(bLayoutMode || bIsWriteable);
						}
						// 11/11/2010   Always create the Required Field Validator so that we can Enable/Disable in a Rule. 
						if ( !bLayoutMode && /* bUI_REQUIRED && */ !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidatorForHiddenInputs reqID = new RequiredFieldValidatorForHiddenInputs();
							reqID.ID                 = sDATA_FIELD + "_REQUIRED";
							reqID.ControlToValidate  = hidID.ID;
							reqID.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqID.CssClass           = "required";
							reqID.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqID.EnableClientScript = false;
							reqID.Enabled            = false;
							// 02/21/2008   Add a little padding. 
							reqID.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqID);
						}
					}
				}
				// 05/17/2009   Add support for a generic module popup. 
				else if ( String.Compare(sFIELD_TYPE, "ModulePopup", true) == 0 )
				{
					//12/07/2009   For cell phones that do not support popups, convert to a DropDownList. 
					if ( !Sql.IsEmptyString(sDATA_FIELD) && !bSupportsPopups )
					{
						ListControl lstField = new DropDownList();
						tdField.Controls.Add(lstField);
						lstField.ID       = sDATA_FIELD;
						lstField.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						lstField.Visible  = bLayoutMode || bIsReadable;
						lstField.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							// 12/04/2005   Don't populate list if this is a post back. 
							if ( (bLayoutMode || !bIsPostBack) )
							{
								try
								{
									using ( DataTable dt = Crm.Modules.Items(sMODULE_TYPE) )
									{
										lstField.DataValueField = "ID"  ;
										lstField.DataTextField  = "NAME";
										lstField.DataSource     = dt;
										lstField.DataBind();
									}
								}
								catch(Exception ex)
								{
									SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
								}
								if ( !bUI_REQUIRED )
								{
									lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
									// 12/02/2007   AppendEditViewFields should be called inside Page_Load when not a postback, 
									// and in InitializeComponent when it is a postback. If done wrong, 
									// the page will bind after the list is populated, causing the list to populate again. 
									// This event will cause the NONE entry to be cleared.  Add a handler to catch this problem, 
									// but the real solution is to call AppendEditViewFields at the appropriate times based on the postback event. 
									lstField.DataBound += new EventHandler(ListControl_DataBound_AllowNull);
								}
							}
							if ( rdr != null )
							{
								// 08/19/2010   Check the list before assigning the value. 
								Utils.SetValue(lstField, Sql.ToGuid(rdr[sDATA_FIELD]).ToString());
							}
							else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
							{
								// 08/19/2010   Check the list before assigning the value. 
								Utils.SetValue(lstField, Security.USER_ID.ToString());
							}
							else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack )
							{
								// 08/19/2010   Check the list before assigning the value. 
								Utils.SetValue(lstField, Security.TEAM_ID.ToString());
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
					else if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TextBox txtNAME = new TextBox();
						tdField.Controls.Add(txtNAME);
						// 10/05/2010   A custom field will not have a display field, but we still want to be able to access by name. 
						txtNAME.ID       = Sql.IsEmptyString(sDISPLAY_FIELD) ? sDATA_FIELD + "_NAME" : sDISPLAY_FIELD;
						txtNAME.ReadOnly = true;
						txtNAME.TabIndex = nFORMAT_TAB_INDEX;
						// 11/25/2006    Turn off viewstate so that we can fix the text on postback. 
						txtNAME.EnableViewState = false;
						// 01/18/2010   Apply ACL Field Security. 
						txtNAME.Visible  = bLayoutMode || bIsReadable;
						txtNAME.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( bLayoutMode )
							{
								txtNAME.Text    = sDISPLAY_FIELD;
								txtNAME.Enabled = false         ;
							}
							// 11/25/2006   The Change text field is losing its value during a postback error. 
							else if ( bIsPostBack )
							{
								// 11/25/2006   In order for this posback fix to work, viewstate must be disabled for this field. 
								if ( tbl.Page.Request[txtNAME.UniqueID] != null )
									txtNAME.Text = Sql.ToString(tbl.Page.Request[txtNAME.UniqueID]);
							}
							else if ( rdr != null )
							{
								// 12/03/2009   We must use vwSchema to look for the desired column name. 
								// 11/22/2010   Convert data reader to data table for Rules Wizard. 
								//if ( vwSchema != null )
								//	vwSchema.RowFilter = "ColumnName = '" + Sql.EscapeSQL(sDISPLAY_FIELD) + "'";
								if ( !Sql.IsEmptyString(sDISPLAY_FIELD) && row != null && rdr.Table.Columns.Contains(sDISPLAY_FIELD) )
									txtNAME.Text = Sql.ToString(rdr[sDISPLAY_FIELD]);
								else
								{
									// 02/16/2010   Move ToGuid to the function so that it can be captured if invalid. 
									txtNAME.Text = Crm.Modules.ItemName(Application, sMODULE_TYPE, rdr[sDATA_FIELD]);
								}
							}
							// 11/25/2006   The team name should always default to the current user's private team. 
							// Make sure not to overwrite the value if this is a postback. 
							// 08/26/2009   Don't prepopulate team or user if in a search dialog. 
							else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack )
								txtNAME.Text = Security.TEAM_NAME;
							// 01/15/2007   Assigned To field will always default to the current user. 
							else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
							{
								// 01/29/2011   If Full Names have been enabled, then prepopulate with the full name. 
								if ( sDISPLAY_FIELD == "ASSIGNED_TO_NAME" )
									txtNAME.Text = Security.FULL_NAME;
								else
									txtNAME.Text = Security.USER_NAME;
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						HtmlInputHidden hidID = new HtmlInputHidden();
						tdField.Controls.Add(hidID);
						hidID.ID = sDATA_FIELD;
						try
						{
							if ( !bLayoutMode )
							{
								if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
									hidID.Value = Sql.ToString(rdr[sDATA_FIELD]);
								// 11/25/2006   The team name should always default to the current user's private team. 
								// Make sure not to overwrite the value if this is a postback. 
								// The hidden field does not require the same viewstate fix as the txtNAME field. 
								// 04/23/2009   Make sure not to initialize the field with an empty guid as that will prevent the required field notice. 
								// 08/26/2009   Don't prepopulate team or user if in a search dialog. 
								else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack && !Sql.IsEmptyGuid(Security.TEAM_ID) )
									hidID.Value = Security.TEAM_ID.ToString();
								// 01/15/2007   Assigned To field will always default to the current user. 
								else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
									hidID.Value = Security.USER_ID.ToString();
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtNAME.Text = ex.Message;
						}
						
						Literal litNBSP = new Literal();
						tdField.Controls.Add(litNBSP);
						litNBSP.Text = "&nbsp;";
						
						// 06/20/2009   The Select button will go on a separate row in the NewRecord form. 
						if ( sLABEL_WIDTH == "100%" && sFIELD_WIDTH == "0%" && nDATA_COLUMNS == 1 )
						{
							nRowIndex++;
							trField = new HtmlTableRow();
							tbl.Rows.Insert(nRowIndex, trField);
							tdField = new HtmlTableCell();
							trField.Cells.Add(tdField);
						}
						HtmlInputButton btnChange = new HtmlInputButton("button");
						tdField.Controls.Add(btnChange);
						// 05/07/2006   Specify a name for the check button so that it can be referenced by SplendidTest. 
						btnChange.ID = sDATA_FIELD + "_btnChange";
						btnChange.Attributes.Add("class", "button");
						// 07/27/2010   We need to allow an onclick to override the default ModulePopup behavior. 
						string[] arrDATA_FORMAT = sDATA_FORMAT.Split(',');
						if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
							btnChange.Attributes.Add("onclick"  , sONCLICK_SCRIPT);
						else
						{
							// 08/01/2010   We need to tell the Users popup to return the FULL NAME. 
							string sQUERY = "null";
							if ( sMODULE_TYPE == "Users" && sDISPLAY_FIELD == "ASSIGNED_TO_NAME" )
								sQUERY = "'FULL_NAME=1'";  // 08/01/201   Query must be quoted. 
							// 07/27/2010   Use the DATA_FORMAT field to determine if the ModulePopup will auto-submit. 
							btnChange.Attributes.Add("onclick"  , "return ModulePopup('" + sMODULE_TYPE + "', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', " + sQUERY + ", " + (arrDATA_FORMAT[0] == "1" ? "true" : "false") + ", null);");
						}
						// 03/31/2007   SugarCRM now uses Select instead of Change. 
						btnChange.Attributes.Add("title"    , L10n.Term(".LBL_SELECT_BUTTON_TITLE"));
						btnChange.Value = L10n.Term(".LBL_SELECT_BUTTON_LABEL");
						// 01/18/2010   Apply ACL Field Security. 
						btnChange.Visible  =   bLayoutMode || bIsReadable;
						btnChange.Disabled = !(bLayoutMode || bIsWriteable);
						
						litNBSP = new Literal();
						tdField.Controls.Add(litNBSP);
						litNBSP.Text = "&nbsp;";
						
						HtmlInputButton btnClear = new HtmlInputButton("button");
						tdField.Controls.Add(btnClear);
						btnClear.ID = sDATA_FIELD + "_btnClear";
						btnClear.Attributes.Add("class", "button");
						// 07/27/2010   Add the ability to submit after clear. 
						btnClear.Attributes.Add("onclick"  , "return ClearModuleType('" + sMODULE_TYPE + "', '" + hidID.ClientID + "', '" + txtNAME.ClientID + "', " + (arrDATA_FORMAT[0] == "1" ? "true" : "false") + ");");
						btnClear.Attributes.Add("title"    , L10n.Term(".LBL_CLEAR_BUTTON_TITLE"));
						btnClear.Value = L10n.Term(".LBL_CLEAR_BUTTON_LABEL");
						// 01/18/2010   Apply ACL Field Security. 
						btnClear.Visible  =   bLayoutMode || bIsReadable;
						btnClear.Disabled = !(bLayoutMode || bIsWriteable);
						
						// 11/11/2010   Always create the Required Field Validator so that we can Enable/Disable in a Rule. 
						if ( !bLayoutMode && /* bUI_REQUIRED && */ !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidatorForHiddenInputs reqID = new RequiredFieldValidatorForHiddenInputs();
							reqID.ID                 = sDATA_FIELD + "_REQUIRED";
							reqID.ControlToValidate  = hidID.ID;
							reqID.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqID.CssClass           = "required";
							reqID.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqID.EnableClientScript = false;
							reqID.Enabled            = false;
							// 02/21/2008   Add a little padding. 
							reqID.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqID);
						}
						// 11/23/2009   Allow AJAX AutoComplete to be turned off. 
						// 01/18/2010   AutoComplete only applies if the field is Writeable. 
						if ( bAjaxAutoComplete && !bLayoutMode && mgrAjax != null && !Sql.IsEmptyString(sMODULE_TYPE) && bIsWriteable )
						{
							string sTABLE_NAME    = Sql.ToString(Application["Modules." + sMODULE_TYPE + ".TableName"   ]);
							string sRELATIVE_PATH = Sql.ToString(Application["Modules." + sMODULE_TYPE + ".RelativePath"]);
							
							// 09/03/2009   File IO is expensive, so cache the results of the Exists test. 
							// 11/19/2009   Simplify the exists test. 
							// 03/03/2010   AutoComplete will not work if the DISPLAY_FIELD is not provided. 
							// 09/08/2010   sRELATIVE_PATH must be valid. 
							// 08/25/2013   File IO is slow, so cache existance test. 
							if ( !Sql.IsEmptyString(sDISPLAY_FIELD) && !Sql.IsEmptyString(sRELATIVE_PATH) && Utils.CachedFileExists(HttpContext.Current, sRELATIVE_PATH + "AutoComplete.asmx") )
							{
								// 09/03/2009   If the AutoComplete file exists, then we can safely diable the ReadOnly flag. 
								txtNAME.ReadOnly = false;
								txtNAME.Attributes.Add("onblur", sTABLE_NAME + "_" + txtNAME.ID + "_Changed(this);");
								// 09/03/2009   Add a PREV_ field so that we can detect a text change. 
								HtmlInputHidden hidPREVIOUS = new HtmlInputHidden();
								tdField.Controls.Add(hidPREVIOUS);
								hidPREVIOUS.ID = "PREV_" + sDISPLAY_FIELD;
								try
								{
									if ( !bLayoutMode )
									{
										if ( !Sql.IsEmptyString(sDISPLAY_FIELD) && rdr != null )
											hidPREVIOUS.Value = Sql.ToString(rdr[sDISPLAY_FIELD]);
										else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack )
											hidPREVIOUS.Value = Security.TEAM_NAME;
										else if ( sEDIT_NAME.IndexOf(".Search") < 0 && sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
										{
											// 01/29/2011   If Full Names have been enabled, then prepopulate with the full name. 
											if ( sDISPLAY_FIELD == "ASSIGNED_TO_NAME" )
												hidPREVIOUS.Value = Security.FULL_NAME;
											else
												hidPREVIOUS.Value = Security.USER_NAME;
										}
									}
								}
								catch(Exception ex)
								{
									SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
								}
								
								AjaxControlToolkit.AutoCompleteExtender auto = new AjaxControlToolkit.AutoCompleteExtender();
								tdField.Controls.Add(auto);
								auto.ID                   = "auto" + txtNAME.ID;
								auto.TargetControlID      = txtNAME.ID;
								auto.ServiceMethod        = sTABLE_NAME + "_" + txtNAME.ID + "_" + "List";
								auto.ServicePath          = sRELATIVE_PATH + "AutoComplete.asmx";
								auto.MinimumPrefixLength  = 2;
								auto.CompletionInterval   = 250;
								auto.EnableCaching        = true;
								// 12/09/2010   Provide a way to customize the AutoComplete.CompletionSetCount. 
								auto.CompletionSetCount   = Crm.Config.CompletionSetCount();
								// 07/27/2010   We need to use the ContextKey feature of AutoComplete to pass the Account Name to the Contact function. 
								// 07/27/2010   JavaScript seems to have a problem with function overloading. 
								// Instead of trying to use function overloading, use a DataFormat flag to check the UseContextKey AutoComplete flag. 
								if ( arrDATA_FORMAT.Length > 1 && arrDATA_FORMAT[1] == "1" )
									auto.UseContextKey = true;
								
								ServiceReference svc = new ServiceReference(sRELATIVE_PATH + "AutoComplete.asmx");
								ScriptReference  scr = new ScriptReference (sRELATIVE_PATH + "AutoComplete.js"  );
								if ( !mgrAjax.Services.Contains(svc) )
									mgrAjax.Services.Add(svc);
								if ( !mgrAjax.Scripts.Contains(scr) )
									mgrAjax.Scripts.Add(scr);
								
								litNBSP = new Literal();
								tdField.Controls.Add(litNBSP);
								litNBSP.Text = "&nbsp;";
								// 09/03/2009   We need to use a unique ID for each ajax error, 
								// otherwise we will not place the error message in the correct location. 
								HtmlGenericControl spnAjaxErrors = new HtmlGenericControl("span");
								tdField.Controls.Add(spnAjaxErrors);
								// 09/03/2009   Don't include the table name in the AjaxErrors field so that 
								// it can be cleared from the ChangeModule() module popup script. 
								spnAjaxErrors.ID = txtNAME.ID + "_AjaxErrors";
								spnAjaxErrors.Attributes.Add("style", "color:Red");
								spnAjaxErrors.EnableViewState = false;
							}
						}
						// 10/20/2010   Automatically associate the TextBox with a Submit button. 
						// 10/20/2010   We are still having a problem with the Enter Key hijacking the Auto-Complete logic. The most practical solution is to block the Enter Key. 
						if ( !bLayoutMode && !Sql.IsEmptyString(sSubmitClientID) )
						{
							if ( mgrAjax != null )
							{
								ScriptManager.RegisterStartupScript(Page, typeof(System.String), txtNAME.ClientID + "_EnterKey", Utils.PreventEnterKeyPress(txtNAME.ClientID), false);
							}
							else
							{
								#pragma warning disable 618
								Page.ClientScript.RegisterStartupScript(typeof(System.String), txtNAME.ClientID + "_EnterKey", Utils.PreventEnterKeyPress(txtNAME.ClientID));
								#pragma warning restore 618
							}
						}
					}
				}
				// 09/02/2009   Add AJAX AutoCompletion
				else if ( String.Compare(sFIELD_TYPE, "ModuleAutoComplete", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TextBox txtField = new TextBox();
						tdField.Controls.Add(txtField);
						txtField.ID       = sDATA_FIELD;
						txtField.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						txtField.Visible  = bLayoutMode || bIsReadable;
						txtField.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							txtField.MaxLength = nFORMAT_MAX_LENGTH   ;
							// 06/20/2009   The NewRecord forms do not specify a size. 
							if ( nFORMAT_SIZE > 0 )
								txtField.Attributes.Add("size", nFORMAT_SIZE.ToString());
							txtField.TextMode  = TextBoxMode.SingleLine;
							// 08/31/2012   Apple and Android devices should support speech and handwriting. 
							// Speech does not work on text areas, only add to single line text boxes. 
							if ( Utils.SupportsSpeech && Sql.ToBoolean(Application["CONFIG.enable_speech"]) )
							{
								txtField.Attributes.Add("speech", "speech");
								txtField.Attributes.Add("x-webkit-speech", "x-webkit-speech");
							}
							if ( bLayoutMode )
							{
								txtField.Text    = sDATA_FIELD;
								txtField.Enabled = false         ;
							}
							else if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
								txtField.Text = Sql.ToString(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtField.Text = ex.Message;
						}
						// 11/23/2009   Allow AJAX AutoComplete to be turned off. 
						// 01/18/2010   AutoComplete only applies if the field is Writeable. 
						if ( bAjaxAutoComplete && !bLayoutMode && mgrAjax != null && !Sql.IsEmptyString(sMODULE_TYPE) && bIsWriteable )
						{
							string sTABLE_NAME    = Sql.ToString(Application["Modules." + sMODULE_TYPE + ".TableName"   ]);
							string sRELATIVE_PATH = Sql.ToString(Application["Modules." + sMODULE_TYPE + ".RelativePath"]);
							
							// 09/03/2009   File IO is expensive, so cache the results of the Exists test. 
							// 11/19/2009   Simplify the exists test. 
							// 09/08/2010   sRELATIVE_PATH must be valid. 
							// 08/25/2013   File IO is slow, so cache existance test. 
							if ( !Sql.IsEmptyString(sRELATIVE_PATH) && Utils.CachedFileExists(HttpContext.Current, sRELATIVE_PATH + "AutoComplete.asmx") )
							{
								AjaxControlToolkit.AutoCompleteExtender auto = new AjaxControlToolkit.AutoCompleteExtender();
								tdField.Controls.Add(auto);
								auto.ID                   = "auto" + txtField.ID;
								auto.TargetControlID      = txtField.ID;
								auto.ServiceMethod        = sTABLE_NAME + "_" + txtField.ID + "_" + "List";
								auto.ServicePath          = sRELATIVE_PATH + "AutoComplete.asmx";
								auto.MinimumPrefixLength  = 2;
								auto.CompletionInterval   = 250;
								auto.EnableCaching        = true;
								// 12/09/2010   Provide a way to customize the AutoComplete.CompletionSetCount. 
								auto.CompletionSetCount   = Crm.Config.CompletionSetCount();
								
								ServiceReference svc = new ServiceReference(sRELATIVE_PATH + "AutoComplete.asmx");
								ScriptReference  scr = new ScriptReference (sRELATIVE_PATH + "AutoComplete.js"  );
								if ( !mgrAjax.Services.Contains(svc) )
									mgrAjax.Services.Add(svc);
								if ( !mgrAjax.Scripts.Contains(scr) )
									mgrAjax.Scripts.Add(scr);
							}
							else
							{
								Application["Exists." + sRELATIVE_PATH + "AutoComplete.asmx"] = false;
							}
						}
						// 06/21/2009   Automatically associate the TextBox with a Submit button. 
						if ( !bLayoutMode && !Sql.IsEmptyString(sSubmitClientID) )
						{
							if ( mgrAjax != null )
							{
								// 06/21/2009   The name of the script block must be unique for each instance of this control. 
								// 06/21/2009   Use RegisterStartupScript instead of RegisterClientScriptBlock so that the script will run after the control has been created. 
								ScriptManager.RegisterStartupScript(Page, typeof(System.String), txtField.ClientID + "_EnterKey", Utils.RegisterEnterKeyPress(txtField.ClientID, sSubmitClientID), false);
							}
							else
							{
								#pragma warning disable 618
								Page.ClientScript.RegisterStartupScript(typeof(System.String), txtField.ClientID + "_EnterKey", Utils.RegisterEnterKeyPress(txtField.ClientID, sSubmitClientID));
								#pragma warning restore 618
							}
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "TextBox", true) == 0 || String.Compare(sFIELD_TYPE, "Password", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TextBox txtField = new TextBox();
						tdField.Controls.Add(txtField);
						txtField.ID       = sDATA_FIELD;
						txtField.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						txtField.Visible  = bLayoutMode || bIsReadable;
						txtField.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( nFORMAT_ROWS > 0 && nFORMAT_COLUMNS > 0 )
							{
								txtField.Rows     = nFORMAT_ROWS   ;
								txtField.Columns  = nFORMAT_COLUMNS;
								txtField.TextMode = TextBoxMode.MultiLine;
								
								// 08/22/2012   Apple and Android devices should support speech and handwriting. 
								// Speech does not work on text areas, only add to single line text boxes. 
								// http://www.labnol.org/software/add-speech-recognition-to-website/19989/
								if ( Utils.SupportsSpeech && Sql.ToBoolean(Application["CONFIG.enable_speech"]) )
								{
									TextBox txtSpeech = new TextBox();
									tdField.Controls.Add(txtSpeech);
									txtSpeech.ID       = sDATA_FIELD + "_SPEECH";
									txtSpeech.TabIndex = nFORMAT_TAB_INDEX;
									txtSpeech.Visible  = bLayoutMode || bIsReadable;
									txtSpeech.Enabled  = bLayoutMode || bIsWriteable;
									txtSpeech.Attributes.Add("style", "width: 15px; height: 20px; border: 0px; background-color: transparent; vertical-align:top;");
									txtSpeech.Attributes.Add("speech", "speech");
									txtSpeech.Attributes.Add("x-webkit-speech", "x-webkit-speech");
									txtSpeech.Attributes.Add("onspeechchange"      , "SpeechTranscribe('" + txtSpeech.ClientID + "', '" + txtField.ClientID + "');");
									txtSpeech.Attributes.Add("onwebkitspeechchange", "SpeechTranscribe('" + txtSpeech.ClientID + "', '" + txtField.ClientID + "');");
								}
							}
							else
							{
								txtField.MaxLength = nFORMAT_MAX_LENGTH   ;
								// 06/20/2009   The NewRecord forms do not specify a size. 
								if ( nFORMAT_SIZE > 0 )
									txtField.Attributes.Add("size", nFORMAT_SIZE.ToString());
								txtField.TextMode  = TextBoxMode.SingleLine;
								// 08/22/2012   Apple and Android devices should support speech and handwriting. 
								// Speech does not work on text areas, only add to single line text boxes. 
								// 08/31/2012  Exclude speech from Password fields. 
								if ( String.Compare(sFIELD_TYPE, "TextBox", true) == 0 && Utils.SupportsSpeech && Sql.ToBoolean(Application["CONFIG.enable_speech"]) )
								{
									txtField.Attributes.Add("speech", "speech");
									txtField.Attributes.Add("x-webkit-speech", "x-webkit-speech");
								}
							}
							if ( bLayoutMode )
							{
								txtField.Text     = sDATA_FIELD;
								txtField.ReadOnly = true       ;
							}
							else if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
							{
								// 11/22/2010   Convert data reader to data table for Rules Wizard. 
								// 11/22/2010   There is no way to get the DbType from a DataTable/DataRow, so just rely upon the detection of Decimal. 
								//int    nOrdinal  = rdr.GetOrdinal(sDATA_FIELD);
								string sTypeName = String.Empty;  // rdr.GetDataTypeName(nOrdinal);
								Type tDATA_FIELD = rdr[sDATA_FIELD].GetType();
								// 03/04/2006   Display currency in the proper format. 
								// Only SQL Server is likely to return the money type, so also include the decimal type. 
								if ( sTypeName == "money" || tDATA_FIELD == typeof(System.Decimal) )
								{
									if ( Sql.IsEmptyString(sDATA_FORMAT) )
										txtField.Text = Sql.ToDecimal(rdr[sDATA_FIELD]).ToString("#,##0.00");
									else
										txtField.Text = Sql.ToDecimal(rdr[sDATA_FIELD]).ToString(sDATA_FORMAT);
								}
								// 01/19/2010   Now that ProjectTask.ESTIMATED_EFFORT is a float, we need to format the value. 
								else if ( tDATA_FIELD == typeof(System.Double) )
								{
									if ( Sql.IsEmptyString(sDATA_FORMAT) )
										txtField.Text = Sql.ToDouble(rdr[sDATA_FIELD]).ToString("0.00");
									else
										txtField.Text = Sql.ToDouble(rdr[sDATA_FIELD]).ToString(sDATA_FORMAT);
								}
								else if ( tDATA_FIELD == typeof(System.Int32) )
								{
									if ( Sql.IsEmptyString(sDATA_FORMAT) )
										txtField.Text = Sql.ToInteger(rdr[sDATA_FIELD]).ToString("0");
									else
										txtField.Text = Sql.ToInteger(rdr[sDATA_FIELD]).ToString(sDATA_FORMAT);
								}
								else
									txtField.Text = Sql.ToString(rdr[sDATA_FIELD]);
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtField.Text = ex.Message;
						}
						if ( String.Compare(sFIELD_TYPE, "Password", true) == 0 )
							txtField.TextMode = TextBoxMode.Password;
						// 09/16/2012   Add onchange event to TextBox. 
						else if ( String.Compare(sFIELD_TYPE, "TextBox", true) == 0 && !bLayoutMode )
						{
							if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
								txtField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
						}
						// 06/21/2009   Automatically associate the TextBox with a Submit button. 
						if ( !bLayoutMode && !Sql.IsEmptyString(sSubmitClientID) )
						{
							if ( mgrAjax != null )
							{
								// 06/21/2009   The name of the script block must be unique for each instance of this control. 
								// 06/21/2009   Use RegisterStartupScript instead of RegisterClientScriptBlock so that the script will run after the control has been created. 
								ScriptManager.RegisterStartupScript(Page, typeof(System.String), txtField.ClientID + "_EnterKey", Utils.RegisterEnterKeyPress(txtField.ClientID, sSubmitClientID), false);
							}
							else
							{
								#pragma warning disable 618
								Page.ClientScript.RegisterStartupScript(typeof(System.String), txtField.ClientID + "_EnterKey", Utils.RegisterEnterKeyPress(txtField.ClientID, sSubmitClientID));
								#pragma warning restore 618
							}
						}
						// 11/11/2010   Always create the Required Field Validator so that we can Enable/Disable in a Rule. 
						if ( !bLayoutMode && /* bUI_REQUIRED && */ !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidator reqNAME = new RequiredFieldValidator();
							reqNAME.ID                 = sDATA_FIELD + "_REQUIRED";
							reqNAME.ControlToValidate  = txtField.ID;
							reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqNAME.CssClass           = "required";
							reqNAME.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqNAME.EnableClientScript = false;
							reqNAME.Enabled            = false;
							reqNAME.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqNAME);
						}
						if ( !bLayoutMode && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							// 01/18/2010   We only need to validate if the field is Writeable. 
							if ( sVALIDATION_TYPE == "RegularExpressionValidator" && !Sql.IsEmptyString(sREGULAR_EXPRESSION) && !Sql.IsEmptyString(sFIELD_VALIDATOR_MESSAGE) && bIsWriteable )
							{
								RegularExpressionValidator reqVALIDATOR = new RegularExpressionValidator();
								reqVALIDATOR.ID                   = sDATA_FIELD + "_VALIDATOR";
								reqVALIDATOR.ControlToValidate    = txtField.ID;
								reqVALIDATOR.ErrorMessage         = L10n.Term(sFIELD_VALIDATOR_MESSAGE);
								reqVALIDATOR.ValidationExpression = sREGULAR_EXPRESSION;
								reqVALIDATOR.CssClass             = "required";
								reqVALIDATOR.EnableViewState      = false;
								// 04/02/2008   We don't enable required fields until we attempt to save. 
								// This is to allow unrelated form actions; the Cancel button is a good example. 
								reqVALIDATOR.EnableClientScript   = false;
								reqVALIDATOR.Enabled              = false;
								reqVALIDATOR.Style.Add("padding-left", "4px");
								tdField.Controls.Add(reqVALIDATOR);
							}
						}
					}
				}
				// 04/02/2009   Add support for FCKEditor to the EditView. 
				else if ( String.Compare(sFIELD_TYPE, "HtmlEditor", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 09/18/2011   Upgrade to CKEditor 3.6.2. 
						CKEditorControl txtField = new CKEditorControl();
						tdField.Controls.Add(txtField);
						txtField.ID         = sDATA_FIELD;
						txtField.Toolbar    = "Taoqi";
						// 09/18/2011   Set the language for CKEditor. 
						txtField.Language   = L10n.NAME;
						txtField.BasePath   = "~/ckeditor/";
						// 04/26/2012   Add file uploader. 
						txtField.FilebrowserUploadUrl    = txtField.ResolveUrl("~/ckeditor/upload.aspx");
						txtField.FilebrowserBrowseUrl    = txtField.ResolveUrl("~/Images/Popup.aspx");
						//txtField.FilebrowserWindowWidth  = "640";
						//txtField.FilebrowserWindowHeight = "480";
						// 01/18/2010   Apply ACL Field Security. 
						txtField.Visible  = bLayoutMode || bIsReadable;
						try
						{
							if ( nFORMAT_ROWS > 0 && nFORMAT_COLUMNS > 0 )
							{
								txtField.Height = nFORMAT_ROWS   ;
								txtField.Width  = nFORMAT_COLUMNS;
							}
							if ( bLayoutMode )
							{
								txtField.Text     = sDATA_FIELD;
							}
							else if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
							{
								txtField.Text = Sql.ToString(rdr[sDATA_FIELD]);
								// 01/18/2010   FCKEditor does not have an Enable field, so just hide and replace with a Literal control. 
								if ( bIsReadable && !bIsWriteable )
								{
									txtField.Visible = false;
									Literal litField = new Literal();
									litField.ID = sDATA_FIELD + "_ReadOnly";
									tdField.Controls.Add(litField);
									litField.Text = Sql.ToString(rdr[sDATA_FIELD]);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							txtField.Text = ex.Message;
						}
						// 04/02/2009   The standard RequiredFieldValidator will not work on the FCKeditor. 
						/*
						if ( !bLayoutMode && bUI_REQUIRED && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							RequiredFieldValidator reqNAME = new RequiredFieldValidator();
							reqNAME.ID                 = sDATA_FIELD + "_REQUIRED";
							reqNAME.ControlToValidate  = txtField.ID;
							reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
							reqNAME.CssClass           = "required";
							reqNAME.EnableViewState    = false;
							// 01/16/2006   We don't enable required fields until we attempt to save. 
							// This is to allow unrelated form actions; the Cancel button is a good example. 
							reqNAME.EnableClientScript = false;
							reqNAME.Enabled            = false;
							reqNAME.Style.Add("padding-left", "4px");
							tdField.Controls.Add(reqNAME);
						}
						*/
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DatePicker", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DatePicker ctlDate = tbl.Page.LoadControl("~/_controls/DatePicker.ascx") as DatePicker;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlDate.NotPostBack = bNotPostBack;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						ctlDate.Visible  = bLayoutMode || bIsReadable;
						ctlDate.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						// 01/16/2006   We validate elsewhere. 
						/*
						if ( !bLayoutMode && bUI_REQUIRED && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							ctlDate.Required = true;
						}
						*/
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateRange", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/17/2007   Use table to align before and after labels. 
						Table tblDateRange = new Table();
						tdField.Controls.Add(tblDateRange);
						TableRow trAfter = new TableRow();
						TableRow trBefore = new TableRow();
						tblDateRange.Rows.Add(trAfter);
						tblDateRange.Rows.Add(trBefore);
						TableCell tdAfterLabel  = new TableCell();
						TableCell tdAfterData   = new TableCell();
						TableCell tdBeforeLabel = new TableCell();
						TableCell tdBeforeData  = new TableCell();
						trAfter .Cells.Add(tdAfterLabel );
						trAfter .Cells.Add(tdAfterData  );
						trBefore.Cells.Add(tdBeforeLabel);
						trBefore.Cells.Add(tdBeforeData );

						// 12/03/2005   UserControls must be loaded. 
						DatePicker ctlDateStart = tbl.Page.LoadControl("~/_controls/DatePicker.ascx") as DatePicker;
						DatePicker ctlDateEnd   = tbl.Page.LoadControl("~/_controls/DatePicker.ascx") as DatePicker;
						Literal litAfterLabel  = new Literal();
						Literal litBeforeLabel = new Literal();
						litAfterLabel .Text = L10n.Term("SavedSearch.LBL_SEARCH_AFTER" );
						litBeforeLabel.Text = L10n.Term("SavedSearch.LBL_SEARCH_BEFORE");
						//tdField.Controls.Add(litAfterLabel );
						//tdField.Controls.Add(ctlDateStart  );
						//tdField.Controls.Add(litBeforeLabel);
						//tdField.Controls.Add(ctlDateEnd    );
						tdAfterLabel .Controls.Add(litAfterLabel );
						tdAfterData  .Controls.Add(ctlDateStart  );
						tdBeforeLabel.Controls.Add(litBeforeLabel);
						tdBeforeData .Controls.Add(ctlDateEnd    );

						ctlDateStart.ID = sDATA_FIELD + "_AFTER";
						ctlDateEnd  .ID = sDATA_FIELD + "_BEFORE";
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlDateStart.NotPostBack = bNotPostBack;
						ctlDateEnd  .NotPostBack = bNotPostBack;
						// 05/10/2006   Set the tab index. 
						ctlDateStart.TabIndex = nFORMAT_TAB_INDEX;
						ctlDateEnd  .TabIndex = nFORMAT_TAB_INDEX;

						// 01/18/2010   Apply ACL Field Security. 
						tblDateRange.Visible  = bLayoutMode || bIsReadable;
						ctlDateStart.Visible  = bLayoutMode || bIsReadable;
						ctlDateStart.Enabled  = bLayoutMode || bIsWriteable;
						// 01/18/2010   Apply ACL Field Security. 
						ctlDateEnd  .Visible  = bLayoutMode || bIsReadable;
						ctlDateEnd  .Enabled  = bLayoutMode || bIsWriteable;
						// 06/21/2009   Move SearchView EnterKey registration from SearchView.asx to here. 
						// 01/18/2010   Don't register the EnterKey unless the date is Writeable. 
						if ( !bLayoutMode && !Sql.IsEmptyString(sSubmitClientID) && bIsWriteable )
						{
							if ( mgrAjax != null )
							{
								// 06/21/2009   The name of the script block must be unique for each instance of this control. 
								// 06/21/2009   Use RegisterStartupScript instead of RegisterClientScriptBlock so that the script will run after the control has been created. 
								ScriptManager.RegisterStartupScript(Page, typeof(System.String), ctlDateStart.DateClientID + "_EnterKey", Utils.RegisterEnterKeyPress(ctlDateStart.DateClientID, sSubmitClientID), false);
								ScriptManager.RegisterStartupScript(Page, typeof(System.String), ctlDateEnd  .DateClientID + "_EnterKey", Utils.RegisterEnterKeyPress(ctlDateEnd  .DateClientID, sSubmitClientID), false);
							}
							else
							{
								#pragma warning disable 618
								Page.ClientScript.RegisterStartupScript(typeof(System.String), ctlDateStart.DateClientID + "_EnterKey", Utils.RegisterEnterKeyPress(ctlDateStart.DateClientID, sSubmitClientID));
								Page.ClientScript.RegisterStartupScript(typeof(System.String), ctlDateEnd  .DateClientID + "_EnterKey", Utils.RegisterEnterKeyPress(ctlDateEnd  .DateClientID, sSubmitClientID));
								#pragma warning restore 618
							}
						}
						try
						{
							if ( rdr != null )
							{
								ctlDateStart.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
								ctlDateEnd  .Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						// 01/16/2006   We validate elsewhere. 
						/*
						if ( !bLayoutMode && bUI_REQUIRED && !Sql.IsEmptyString(sDATA_FIELD) )
						{
							ctlDateStart.Required = true;
							ctlDateEnd  .Required = true;
						}
						*/
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateTimePicker", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DateTimePicker ctlDate = tbl.Page.LoadControl("~/_controls/DateTimePicker.ascx") as DateTimePicker;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlDate.NotPostBack = bNotPostBack;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						ctlDate.Visible  = bLayoutMode || bIsReadable;
						ctlDate.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "DateTimeEdit", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DateTimeEdit ctlDate = tbl.Page.LoadControl("~/_controls/DateTimeEdit.ascx") as DateTimeEdit;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlDate.NotPostBack = bNotPostBack;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						ctlDate.Visible  = bLayoutMode || bIsReadable;
						ctlDate.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( !bLayoutMode && bUI_REQUIRED )
						{
							ctlDate.EnableNone = false;
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				// 06/20/2009   Add DateTimeNewRecord so that the NewRecord forms can use the Dynamic rendering. 
				else if ( String.Compare(sFIELD_TYPE, "DateTimeNewRecord", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						// 12/03/2005   UserControls must be loaded. 
						DateTimeEdit ctlDate = tbl.Page.LoadControl("~/_controls/DateTimeNewRecord.ascx") as DateTimeEdit;
						tdField.Controls.Add(ctlDate);
						ctlDate.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlDate.NotPostBack = bNotPostBack;
						// 05/10/2006   Set the tab index. 
						ctlDate.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						ctlDate.Visible  = bLayoutMode || bIsReadable;
						ctlDate.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							if ( rdr != null )
								ctlDate.Value = T10n.FromServerTime(rdr[sDATA_FIELD]);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( !bLayoutMode && bUI_REQUIRED )
						{
							ctlDate.EnableNone = false;
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "File", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						HtmlInputHidden ctlHidden = null;
						if ( !bLayoutMode )
						{
							HtmlInputFile ctlField = new HtmlInputFile();
							tdField.Controls.Add(ctlField);
							// 04/17/2006   The image needs to reference the file control. 
							// 11/25/2010   Appending _File breaks the previous behavior of Notes, Bugs and Documents.
							// 11/25/2010   The file field is special in that it may not exist as a table column. 
							// 12/01/2010   rdr will not be available during postback, so we cannot use it do determine the field name. 
							// 12/01/2010   The only solution is to fix the naming convention for Notes, Bugs and Documents. 
							//if ( rdr != null && rdr.Table.Columns.Contains(sDATA_FIELD) )
							{
								ctlField.ID = sDATA_FIELD + "_File";
								ctlHidden = new HtmlInputHidden();
								tdField.Controls.Add(ctlHidden);
								ctlHidden.ID = sDATA_FIELD;
							}
							//else
							//{
							//	ctlField.ID = sDATA_FIELD;
							//}
							ctlField.MaxLength = nFORMAT_MAX_LENGTH;
							ctlField.Size      = nFORMAT_SIZE;
							ctlField.Attributes.Add("TabIndex", nFORMAT_TAB_INDEX.ToString());
							// 01/18/2010   Apply ACL Field Security. 
							ctlField.Visible  =   bLayoutMode || bIsReadable;
							ctlField.Disabled = !(bLayoutMode || bIsWriteable);

							Literal litBR = new Literal();
							litBR.Text = "<br />";
							tdField.Controls.Add(litBR);

							// 11/11/2010   Always create the Required Field Validator so that we can Enable/Disable in a Rule. 
							if ( !bLayoutMode /* && bUI_REQUIRED */ )
							{
								RequiredFieldValidator reqNAME = new RequiredFieldValidator();
								reqNAME.ID                 = sDATA_FIELD + "_REQUIRED";
								reqNAME.ControlToValidate  = ctlField.ID;
								reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
								reqNAME.CssClass           = "required";
								reqNAME.EnableViewState    = false;
								// 01/16/2006   We don't enable required fields until we attempt to save. 
								// This is to allow unrelated form actions; the Cancel button is a good example. 
								reqNAME.EnableClientScript = false;
								reqNAME.Enabled            = false;
								reqNAME.Style.Add("padding-left", "4px");
								tdField.Controls.Add(reqNAME);
							}
						}
						
						// 11/23/2010   File needs to act like an Image. 
						HyperLink lnkField = new HyperLink();
						// 04/13/2006   Give the image a name so that it can be validated with SplendidTest. 
						lnkField.ID = "lnk" + sDATA_FIELD;
						// 01/18/2010   Apply ACL Field Security. 
						lnkField.Visible  = bLayoutMode || bIsReadable;
						try
						{
							if ( bLayoutMode )
							{
								Literal litField = new Literal();
								litField.Text = sDATA_FIELD;
								tdField.Controls.Add(litField);
							}
							else if ( rdr != null && rdr.Table.Columns.Contains(sDATA_FIELD) )
							{
								// 11/25/2010   The file field is special in that it may not exist as a table column. 
								if ( ctlHidden != null && !Sql.IsEmptyString(rdr[sDATA_FIELD]) )
								{
									ctlHidden.Value = Sql.ToString(rdr[sDATA_FIELD]);
									lnkField.NavigateUrl = "~/Images/Image.aspx?ID=" + ctlHidden.Value;
									lnkField.Text = Crm.Modules.ItemName(Application, "Images", ctlHidden.Value);
									// 04/13/2006   Only add the image if it exists. 
									tdField.Controls.Add(lnkField);
									
									// 04/17/2006   Provide a clear button. 
									Literal litClear = new Literal();
									litClear.Text = "&nbsp; <input type=\"button\" class=\"button\" onclick=\"document.getElementById('" + ctlHidden.ClientID + "').value='';document.getElementById('" + lnkField.ClientID + "').innerHTML='';" + "\"  value='" + "  " + L10n.Term(".LBL_CLEAR_BUTTON_LABEL" ) + "  " + "' title='" + L10n.Term(".LBL_CLEAR_BUTTON_TITLE" ) + "' />";
									tdField.Controls.Add(litClear);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							Literal litField = new Literal();
							litField.Text = ex.Message;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "Image", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						HtmlInputHidden ctlHidden = new HtmlInputHidden();
						if ( !bLayoutMode )
						{
							tdField.Controls.Add(ctlHidden);
							ctlHidden.ID = sDATA_FIELD;

							HtmlInputFile ctlField = new HtmlInputFile();
							tdField.Controls.Add(ctlField);
							// 04/17/2006   The image needs to reference the file control. 
							ctlField.ID = sDATA_FIELD + "_File";
							ctlField.MaxLength = nFORMAT_MAX_LENGTH;
							ctlField.Size      = nFORMAT_SIZE;
							ctlField.Attributes.Add("TabIndex", nFORMAT_TAB_INDEX.ToString());
							// 01/18/2010   Apply ACL Field Security. 
							ctlField.Visible  =   bLayoutMode || bIsReadable;
							ctlField.Disabled = !(bLayoutMode || bIsWriteable);

							Literal litBR = new Literal();
							litBR.Text = "<br />";
							tdField.Controls.Add(litBR);

							// 11/25/2010   Add required field validator. 
							if ( !bLayoutMode /* && bUI_REQUIRED */ )
							{
								RequiredFieldValidator reqNAME = new RequiredFieldValidator();
								reqNAME.ID                 = sDATA_FIELD + "_REQUIRED";
								reqNAME.ControlToValidate  = ctlField.ID;
								reqNAME.ErrorMessage       = L10n.Term(".ERR_REQUIRED_FIELD");
								reqNAME.CssClass           = "required";
								reqNAME.EnableViewState    = false;
								// 01/16/2006   We don't enable required fields until we attempt to save. 
								// This is to allow unrelated form actions; the Cancel button is a good example. 
								reqNAME.EnableClientScript = false;
								reqNAME.Enabled            = false;
								reqNAME.Style.Add("padding-left", "4px");
								tdField.Controls.Add(reqNAME);
							}
						}
						
						Image imgField = new Image();
						// 04/13/2006   Give the image a name so that it can be validated with SplendidTest. 
						imgField.ID = "img" + sDATA_FIELD;
						// 01/18/2010   Apply ACL Field Security. 
						imgField.Visible  = bLayoutMode || bIsReadable;
						try
						{
							if ( bLayoutMode )
							{
								Literal litField = new Literal();
								litField.Text = sDATA_FIELD;
								tdField.Controls.Add(litField);
							}
							else if ( rdr != null )
							{
								if ( !Sql.IsEmptyString(rdr[sDATA_FIELD]) )
								{
									ctlHidden.Value = Sql.ToString(rdr[sDATA_FIELD]);
									imgField.ImageUrl = "~/Images/Image.aspx?ID=" + ctlHidden.Value;
									// 04/13/2006   Only add the image if it exists. 
									tdField.Controls.Add(imgField);
									
									// 04/17/2006   Provide a clear button. 
									Literal litClear = new Literal();
									litClear.Text = "&nbsp; <input type=\"button\" class=\"button\" onclick=\"document.getElementById('" + ctlHidden.ClientID + "').value='';document.getElementById('" + imgField.ClientID + "').src='';" + "\"  value='" + "  " + L10n.Term(".LBL_CLEAR_BUTTON_LABEL" ) + "  " + "' title='" + L10n.Term(".LBL_CLEAR_BUTTON_TITLE" ) + "' />";
									tdField.Controls.Add(litClear);
								}
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
							Literal litField = new Literal();
							litField.Text = ex.Message;
							tdField.Controls.Add(litField);
						}
					}
				}
				else if ( String.Compare(sFIELD_TYPE, "AddressButtons", true) == 0 && (btnCopyRight == null) && (btnCopyLeft == null) )
				{
					trField.Cells.Remove(tdField);
					tdLabel.Width = "10%";
					tdLabel.RowSpan = nROWSPAN;
					tdLabel.VAlign  = "middle";
					tdLabel.Align   = "center";
					tdLabel.Attributes.Remove("class");
					tdLabel.Attributes.Add("class", "tabFormAddDel");
					// 05/08/2010   Define the copy buttons outside the loop so that we can replace the javascriptwith embedded code.  
					// This is so that the javascript will run properly in the SixToolbar UpdatePanel. 
					btnCopyRight = new HtmlInputButton("button");
					btnCopyLeft  = new HtmlInputButton("button");
					Literal         litSpacer    = new Literal();
					tdLabel.Controls.Add(btnCopyRight);
					tdLabel.Controls.Add(litSpacer   );
					tdLabel.Controls.Add(btnCopyLeft );
					btnCopyRight.Attributes.Add("title"  , L10n.Term("Accounts.NTC_COPY_BILLING_ADDRESS" ));
					//btnCopyRight.Attributes.Add("onclick", "return copyAddressRight()");
					btnCopyRight.Value = ">>";
					litSpacer.Text = "<br><br>";
					btnCopyLeft .Attributes.Add("title"  , L10n.Term("Accounts.NTC_COPY_SHIPPING_ADDRESS" ));
					//btnCopyLeft .Attributes.Add("onclick", "return copyAddressLeft()");
					btnCopyLeft .Value = "<<";
					nColIndex = 0;
				}
				else if ( String.Compare(sFIELD_TYPE, "Hidden", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						HtmlInputHidden hidID = new HtmlInputHidden();
						tdField.Controls.Add(hidID);
						hidID.ID = sDATA_FIELD;
						try
						{
							if ( bLayoutMode )
							{
								TextBox txtNAME = new TextBox();
								tdField.Controls.Add(txtNAME);
								txtNAME.ReadOnly = true;
								// 11/25/2006    Turn off viewstate so that we can fix the text on postback. 
								txtNAME.EnableViewState = false;
								txtNAME.Text    = sDATA_FIELD;
								txtNAME.Enabled = false         ;
							}
							else
							{
								// 02/28/2008   When the hidden field is the first in the row, we end up with a blank row. 
								// Just ignore for now as IE does not have a problem with the blank row. 
								nCOLSPAN = -1;
								trLabel.Cells.Remove(tdLabel);
								tdField.Attributes.Add("style", "display:none");
								if ( !Sql.IsEmptyString(sDATA_FIELD) && rdr != null )
									hidID.Value = Sql.ToString(rdr[sDATA_FIELD]);
								// 11/25/2006   The team name should always default to the current user's private team. 
								// Make sure not to overwrite the value if this is a postback. 
								// The hidden field does not require the same viewstate fix as the txtNAME field. 
								else if ( sDATA_FIELD == "TEAM_ID" && rdr == null && !bIsPostBack )
									hidID.Value = Security.TEAM_ID.ToString();
								// 01/15/2007   Assigned To field will always default to the current user. 
								else if ( sDATA_FIELD == "ASSIGNED_USER_ID" && rdr == null && !bIsPostBack )
									hidID.Value = Security.USER_ID.ToString();
							}
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
					}
				}
				// 08/24/2009   Add support for dynamic teams. 
				else if ( String.Compare(sFIELD_TYPE, "TeamSelect", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						TeamSelect ctlTeamSelect = tbl.Page.LoadControl("~/_controls/TeamSelect.ascx") as TeamSelect;
						tdField.Controls.Add(ctlTeamSelect);
						ctlTeamSelect.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlTeamSelect.NotPostBack = bNotPostBack;
						//ctlTeamSelect.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						ctlTeamSelect.Visible  = bLayoutMode || bIsReadable;
						ctlTeamSelect.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							Guid gTEAM_SET_ID = Guid.Empty;
							if ( rdr != null )
							{
								// 11/22/2010   Convert data reader to data table for Rules Wizard. 
								//vwSchema.RowFilter = "ColumnName = 'TEAM_SET_ID'";
								//if ( vwSchema.Count > 0 )
								if ( rdr.Table.Columns.Contains("TEAM_SET_ID") )
								{
									gTEAM_SET_ID = Sql.ToGuid(rdr["TEAM_SET_ID"]);
								}
							}
							// 08/31/2009  Don't provide defaults in a Search view or a Popup view. 
							bool bAllowDefaults = sEDIT_NAME.IndexOf(".Search") < 0 && sEDIT_NAME.IndexOf(".Popup") < 0;
							ctlTeamSelect.LoadLineItems(gTEAM_SET_ID, bAllowDefaults);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				// 10/21/2009   Add support for dynamic teams. 
				else if ( String.Compare(sFIELD_TYPE, "KBTagSelect", true) == 0 )
				{
					if ( !Sql.IsEmptyString(sDATA_FIELD) )
					{
						KBTagSelect ctlKBTagSelect = tbl.Page.LoadControl("~/_controls/KBTagSelect.ascx") as KBTagSelect;
						tdField.Controls.Add(ctlKBTagSelect);
						ctlKBTagSelect.ID = sDATA_FIELD;
						// 05/06/2010   Use a special Page flag to override the default IsPostBack behavior. 
						ctlKBTagSelect.NotPostBack = bNotPostBack;
						//ctlKBTagSelect.TabIndex = nFORMAT_TAB_INDEX;
						// 01/18/2010   Apply ACL Field Security. 
						ctlKBTagSelect.Visible  = bLayoutMode || bIsReadable;
						ctlKBTagSelect.Enabled  = bLayoutMode || bIsWriteable;
						try
						{
							Guid gID = Guid.Empty;
							if ( rdr != null )
							{
								gID = Sql.ToGuid(rdr["ID"]);
							}
							ctlKBTagSelect.LoadLineItems(gID);
						}
						catch(Exception ex)
						{
							SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
						}
						if ( bLayoutMode )
						{
							Literal litField = new Literal();
							litField.Text = sDATA_FIELD;
							tdField.Controls.Add(litField);
						}
					}
				}
				else
				{
					Literal litField = new Literal();
					tdField.Controls.Add(litField);
					litField.Text = "Unknown field type " + sFIELD_TYPE;
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), "Unknown field type " + sFIELD_TYPE);
				}
				// 12/02/2007   Each view can now have its own number of data columns. 
				// This was needed so that search forms can have 4 data columns. The default is 2 columns. 
				if ( nCOLSPAN > 0 )
					nColIndex += nCOLSPAN;
				else if ( nCOLSPAN == 0 )
					nColIndex++;
				if ( nColIndex >= nDATA_COLUMNS )
					nColIndex = 0;
			}
			// 09/20/2012   We need a SCRIPT field that is form specific. 
			if ( dvFields.Count > 0 && !bLayoutMode )
			{
				try
				{
					string sEDIT_NAME   = Sql.ToString(dvFields[0]["EDIT_NAME"]);
					string sFORM_SCRIPT = Sql.ToString(dvFields[0]["SCRIPT"   ]);
					if ( !Sql.IsEmptyString(sFORM_SCRIPT) )
					{
						// 09/20/2012   The base ID is not the ID of the parent, but the ID of the TemplateControl. 
						sFORM_SCRIPT = sFORM_SCRIPT.Replace("SPLENDID_EDITVIEW_LAYOUT_ID", tbl.TemplateControl.ClientID);
						ScriptManager.RegisterStartupScript(tbl, typeof(System.String), sEDIT_NAME.Replace(".", "_") + "_SCRIPT", sFORM_SCRIPT, true);
					}
				}
				catch(Exception ex)
				{
					SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
				}
			}
			// 05/08/2010   Define the copy buttons outside the loop so that we can replace the javascript with embedded code.  
			// This is so that the javascript will run properly in the SixToolbar UpdatePanel. 
			if ( btnCopyRight != null && btnCopyLeft != null )
			{
				string[][] arrCopyFields = new string[14][];
				arrCopyFields[0] = new string[2] { "SHIPPING_ADDRESS_STREET"    , "BILLING_ADDRESS_STREET"    };
				arrCopyFields[1] = new string[2] { "SHIPPING_ADDRESS_CITY"      , "BILLING_ADDRESS_CITY"      };
				arrCopyFields[2] = new string[2] { "SHIPPING_ADDRESS_STATE"     , "BILLING_ADDRESS_STATE"     };
				arrCopyFields[3] = new string[2] { "SHIPPING_ADDRESS_POSTALCODE", "BILLING_ADDRESS_POSTALCODE"};
				arrCopyFields[4] = new string[2] { "SHIPPING_ADDRESS_COUNTRY"   , "BILLING_ADDRESS_COUNTRY"   };
				arrCopyFields[5] = new string[2] { "ALT_ADDRESS_STREET"         , "PRIMARY_ADDRESS_STREET"    };
				arrCopyFields[6] = new string[2] { "ALT_ADDRESS_CITY"           , "PRIMARY_ADDRESS_CITY"      };
				arrCopyFields[7] = new string[2] { "ALT_ADDRESS_STATE"          , "PRIMARY_ADDRESS_STATE"     };
				arrCopyFields[8] = new string[2] { "ALT_ADDRESS_POSTALCODE"     , "PRIMARY_ADDRESS_POSTALCODE"};
				arrCopyFields[9] = new string[2] { "ALT_ADDRESS_COUNTRY"        , "PRIMARY_ADDRESS_COUNTRY"   };
				// 08/21/2010   Also copy Account and Contact on Quotes, Orders and Invoices. 
				arrCopyFields[10] = new string[2] { "SHIPPING_ACCOUNT_NAME"      , "BILLING_ACCOUNT_NAME"      };
				arrCopyFields[11] = new string[2] { "SHIPPING_ACCOUNT_ID"        , "BILLING_ACCOUNT_ID"        };
				arrCopyFields[12] = new string[2] { "SHIPPING_CONTACT_NAME"      , "BILLING_CONTACT_NAME"      };
				arrCopyFields[13] = new string[2] { "SHIPPING_CONTACT_ID"        , "BILLING_CONTACT_ID"        };

				/*
				function copyAddressRight()
				{
					document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_STREET"    ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_STREET"    ).ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_CITY"      ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_CITY"      ).ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_STATE"     ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_STATE"     ).ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_POSTALCODE").ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_POSTALCODE").ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_COUNTRY"   ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_COUNTRY"   ).ClientID %>').value;
					return true;
				}
				function copyAddressLeft()
				{
					document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_STREET"    ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_STREET"    ).ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_CITY"      ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_CITY"      ).ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_STATE"     ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_STATE"     ).ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_POSTALCODE").ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_POSTALCODE").ClientID %>').value;
					document.getElementById('<%= new DynamicControl(this, "BILLING_ADDRESS_COUNTRY"   ).ClientID %>').value = document.getElementById('<%= new DynamicControl(this, "SHIPPING_ADDRESS_COUNTRY"   ).ClientID %>').value;
					return true;
				}
				*/
				StringBuilder sbCopyRight = new StringBuilder();
				StringBuilder sbCopyLeft  = new StringBuilder();
				for ( int i = 0; i < arrCopyFields.Length; i++ )
				{
					Control ctl1 = tbl.FindControl(arrCopyFields[i][0]);
					Control ctl2 = tbl.FindControl(arrCopyFields[i][1]);
					if ( ctl1 != null && ctl2 != null )
					{
						// 02/01/2011   Cannot copy values from literal. 
						if ( !(ctl1 is Literal) && !(ctl2 is Literal) )
						{
							sbCopyRight.Append("document.getElementById('" + ctl1.ClientID + "').value = document.getElementById('" + ctl2.ClientID + "').value;");
							sbCopyLeft .Append("document.getElementById('" + ctl2.ClientID + "').value = document.getElementById('" + ctl1.ClientID + "').value;");
						}
					}
				}
				sbCopyRight.Append("return true;");
				sbCopyLeft .Append("return true;");

				btnCopyRight.Attributes.Add("onclick", sbCopyRight.ToString());
				btnCopyLeft .Attributes.Add("onclick", sbCopyLeft .ToString());
			}
		}
        /// <summary>
        /// Lägger till varje fråga i paneln och visar om man har svarat rätt eller fel. 
        /// </summary>
        /// <param name="queID"></param>
        /// <param name="ttID"></param>
        private void fillData(string queID, string ttID)
        {
            clsFillQuestion quest = new clsFillQuestion();
            Tuple<DataTable, string, int, string, string> Que = quest.readXML(queID, ttID);
            DataTable dt = Que.Item1;

            Label lbN = new Label();
            string img = "";
            if (Que.Item5 != null)
            {
                img = "<img src='pictures/" + Que.Item5 + "' style='height: 150px; width: 150px;'alt='bilden' />";
            }
            lbN.ID = "QUEST_" + queID;
            lbN.Text = "<h5>" + Que.Item2 + "</h5> " + img  + "<br />";

            panData.Controls.Add(lbN);
            int many = 0;
            for (int i = 0; i < Que.Item1.Rows.Count; i++)
            {
                if (Que.Item1.Rows[i]["answ"].ToString().ToUpper() == "TRUE")
                {
                    many += 1;
                }
            }
            if (many > 1) //Om det finns flera valmöjligheter så sätter vi ut en checkboxliist
            {
                CheckBoxList li = new CheckBoxList();
                li.ID = queID;
                li.DataTextField = "name";
                li.DataValueField = "id";
                li.DataSource = dt;
                li.DataBind();
                li.Enabled = false;
                for (int i = 0; i < dt.Rows.Count; i++)  //KRyssar i de som redan användaren har kryssat i
                {
                    int val = 0;
                    if (dt.Rows[i]["sel"].ToString().ToUpper() == "TRUE")
                    {
                        if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
                        {
                            li.Items.FindByValue(val.ToString()).Selected = true; //Sätter alla som finns till true så att den kan vara multippella
                            li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid red;");
                        }
                        val = 0;
                    }
                    if (dt.Rows[i]["answ"].ToString().ToUpper() == "TRUE")
                    {
                        if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
                        {
                            li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid green;"); //= System.Drawing.Color.Green; //Sätter alla som finns till true så att den kan vara multippella
                        }
                        val = 0;
                    }
                }
                panData.Controls.Add(li);
            }
            else
            {
                RadioButtonList li = new RadioButtonList();
                li.ID = queID;
                li.DataTextField = "name";
                li.DataValueField = "id";
                li.DataSource = Que.Item1;
                li.DataBind();
                li.Enabled = false;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int val = 0;
                    if (dt.Rows[i]["sel"].ToString().ToUpper() == "TRUE")
                    {
                        if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
                        {
                            li.SelectedValue = val.ToString();
                            li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid red;");
                        }
                    }
                    if (dt.Rows[i]["answ"].ToString().ToUpper() == "TRUE") //Om man vill kolla på frågorna igen så markeras den grön om det är okej
                    {
                        if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
                        {
                            li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid green;");
                        }
                    }
                }
                panData.Controls.Add(li);
            }
        }
Exemple #38
0
        public void FillRadiobtnList(ref RadioButtonList objrbtnList, string strQuery, string strTextField, string strValueField, string strOrderBy, string strQueryCondition = "")
        {
            dsCommon = new DataSet();
            dsCommon = CrystalConnection.CreateDatasetWithoutTransaction(strQuery + " " + strQueryCondition + " " + strOrderBy);

            objrbtnList.DataTextField = strTextField;
            objrbtnList.DataValueField = strValueField;
            objrbtnList.DataSource = dsCommon.Tables[0].DefaultView;
            objrbtnList.DataBind();
        }
        protected void CreatePetsTable(List<Pet> myPets)
        {
            decimal saving = 0;
            decimal firstMonthTotal = 0;
            decimal recurringTotal = 0;
            decimal annualTotal = 0;
            decimal discountsMonthlyTotal = 0;
            decimal discountsAnnualTotal = 0;
            Table tGender = new Table();
            short sPetCount = 0;

            string sRowLayout = @"<div class='row'>
                <div class='col-lg-3 col-sm-3 petchart'><h3>{0}</h3>

                </div>
                <div class='col-lg-2 col-sm-3 petchart'>
                <div>Annual Limit: {1}</div>
                <div>Deductible: {2}</div>
                <div>Reimbursement: {3}</div>
                <div>Routine Care: {4}</div>
                </div>";

            string sMonthlyTotalAllPets = @"<div class='col-lg-2 col-sm-3 petchart petchartsize'>
                                            <div>First Month: {0}</div>
                                            <div>Per Month: {1}</div>
                                            </div>";

            string sYearlyTotalAllPets = @"<div class='col-lg-2 col-sm-3 petchart petchartsize'>
                                    <div>Annually: {0}</div>
                                    </div>";

            string sMonthlyTotalAllPets1 = @"<div class='col-lg-2 col-sm-3 petchart1 petchartsize'>
                                            <div>First Month: {0}</div>
                                            <div>Per Month: {1}</div>
                                            </div>";

            string sYearlyTotalAllPets1 = @"<div class='col-lg-2 col-sm-3 petchart1 petchartsize'>
                                    <div>Annually: {0}</div>
                                    </div>";

            string sMonthlyTotalAllPets2 = @"<div class='col-lg-2 col-sm-3'>
                                            <h3>All Pets</h3>
                                            <div>First Month: {0}</div>
                                            <div>Per Month: {1}</div>
                                            </div>";

            string sYearlyTotalAllPets2 = @"<div class='col-lg-2 col-sm-3'>
                                    <h3>All Pets</h3>
                                    <div>Annually: {0}</div>
                                    </div>";

            string sPetFiller = @"<div class='col-lg-2 col-sm-3 petchart2 petchartsize'></div>";

            string sPetFiller2 = @"<div class='col-lg-2 col-sm-3 petchart3 petchartsize'></div>";

            string sTableInnerHTML = "";

            foreach (Pet p in myPets)
            {

                    firstMonthTotal += p.FirstMonthPaymentTotal;
                    recurringTotal += p.RecurringMonthPaymentTotal;
                    annualTotal += p.AnnualPaymentTotal;
                    discountsMonthlyTotal += p.InternetDiscountAmount +
                                              p.EBDiscountAmount +
                                              p.MilitaryDiscountAmount +
                                              p.VetDiscountAmount;
            }

            saving = firstMonthTotal + recurringTotal * 11 - annualTotal;

            discountsAnnualTotal = discountsMonthlyTotal + saving;

            if (!bAnnual)
            {
                lblDiscounts.Text = discountsMonthlyTotal.ToString("C2");
            }
            else
            {
                lblDiscounts.Text = discountsAnnualTotal.ToString("C2");
            }

            sPetCount = 0;

            string sMonthlyTotalThisPet = "";
            string sYearlyTotalThisPet = "";
            foreach (Pet p in myPets)
            {
                sTableInnerHTML += string.Format(sRowLayout, p.PetName,
                                                        p.LimitAmount.ToString("C2"),
                                                        p.DeductibleAmount.ToString("C2"),
                                                        p.Reimbursement.ToString("P0"),
                                                        GetRiderName(p.Routine),
                                                        p.FirstMonthPaymentTotal.ToString("C2"),
                                                        p.RecurringMonthPaymentTotal.ToString("C2"),
                                                        sPetCount);

                    sMonthlyTotalThisPet = @"<div class='col-lg-2 col-sm-3 petchart'>
                                            <div>First Month: {0}</div>
                                            <div>Per Month: {1}</div>
                                            </div>";

                    sYearlyTotalThisPet = @"<div class='col-lg-2 col-sm-3 petchart'>
                                    <div>Annually: {0}</div>
                                    </div>";

                if (!bAnnual)
                {
                    sTableInnerHTML += string.Format(sMonthlyTotalThisPet, p.FirstMonthPaymentTotal.ToString("C2"),
                                                               p.RecurringMonthPaymentTotal.ToString("C2"));
                    lblAnnualSavings.Text = saving.ToString("C2");
                    btnAnnualSavings.Visible = true;
                }
                else
                {
                    sTableInnerHTML += string.Format(sYearlyTotalThisPet, p.AnnualPaymentTotal.ToString("C2"));
                    btnAnnualSavings.Visible = false;
                }

                if (sPetCount == 0 && sPetCount + 1 != myPets.Count) //no bottom
                {

                    if (!bAnnual)
                    {
                        sTableInnerHTML += string.Format(sMonthlyTotalAllPets1, firstMonthTotal.ToString("C2"),
                                                                   recurringTotal.ToString("C2"));
                        lblAnnualSavings.Text = saving.ToString("C2");
                        btnAnnualSavings.Visible = true;
                    }
                    else
                    {
                        sTableInnerHTML += string.Format(sYearlyTotalAllPets1, annualTotal.ToString("C2"));
                        btnAnnualSavings.Visible = false;
                    }
                }
                else if (sPetCount == 0) // all corners
                {
                    if (!bAnnual)
                    {
                        sTableInnerHTML += string.Format(sMonthlyTotalAllPets, firstMonthTotal.ToString("C2"),
                                                                   recurringTotal.ToString("C2"));
                        lblAnnualSavings.Text = saving.ToString("C2");
                        btnAnnualSavings.Visible = true;
                    }
                    else
                    {
                        sTableInnerHTML += string.Format(sYearlyTotalAllPets, annualTotal.ToString("C2"));
                        btnAnnualSavings.Visible = false;
                    }
                }
                else if (sPetCount + 1 == myPets.Count) //bottom no top
                {
                    sTableInnerHTML += sPetFiller;
                }
                else //sides only
                {
                    //sTableInnerHTML += "<div class='col-lg-2 col-sm-3'></div></div>";
                    sTableInnerHTML += sPetFiller2;
                }

                sTableInnerHTML += "</div>";

                TableRow trPet = new TableRow();
                TableCell tcPetName = new TableCell();
                TableCell tcGender = new TableCell();
                Label lblPetName = new Label();
                lblPetName.ID = "lblPetName" + sPetCount.ToString();
                lblPetName.Text = p.PetName;
                lblPetName.CssClass = "customlabel2";
                RadioButtonList rblPetGender = new RadioButtonList();
                lblPetName.AssociatedControlID = rblPetGender.ID = "rblPetGender" + sPetCount.ToString();
                rblPetGender.Items.Add(new ListItem("Male", "1"));
                rblPetGender.Items.Add(new ListItem("Female", "2"));
                rblPetGender.SelectedIndex = 0;
                //rblPetGender.AutoPostBack = true;
                //rblPetGender.SelectedIndexChanged += new EventHandler(rblPetGender_SelectedIndexChanged);
                rblPetGender.DataBind();
                rblPetGender.RepeatLayout = RepeatLayout.Table;
                rblPetGender.RepeatDirection = RepeatDirection.Horizontal;
                //PetDetailsPetName.Controls.Add(lblPetName);
                //PetDetailsPetGender.Controls.Add(lblPetName);
                //PetDetailsPetGender.Controls.Add(rblPetGender);
                tcPetName.Controls.Add(lblPetName);
                tcGender.Controls.Add(rblPetGender);
                trPet.Cells.Add(tcPetName);
                trPet.Cells.Add(tcGender);
                tblPetGender.Rows.Add(trPet);
                sPetCount++;

            }
            PetsTable.InnerHtml = sTableInnerHTML;

            if (bAnnual)
            {
                PetsTableTotalSmall.InnerHtml = string.Format(sYearlyTotalAllPets2, annualTotal.ToString("C2"));
            }
            else
            {
                PetsTableTotalSmall.InnerHtml = string.Format(sMonthlyTotalAllPets2, firstMonthTotal.ToString("C2"), recurringTotal.ToString("C2"));
            }
        }
Exemple #40
0
/**
 */
        public void BindData()
        {
            //declare variables
            string strSQL;
            string myConnectString;

            //check to see if we already know what type of adType posting this will be
            string[] qAdType;
            qAdType = Request.QueryString.GetValues("q");
            if (qAdType != null)
            {
                hdnAdType.Value = HttpUtility.UrlDecode(qAdType[0].ToString());
                qAdType[0]      = string.Empty;
            }
            else
            {
                //unknown type
                hdnAdType.Value = "0";
            }

            //Create connect string
            myConnectString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;

            //Build SQL statement
            strSQL = "SELECT * FROM LK_Region ORDER BY Description DESC; SELECT iD,condition FROM LK_Condition";

            SqlConnection myConnection = new SqlConnection(myConnectString);

            // Read sample item info from SQL into a DataSet
            DataSet        dsItems    = new DataSet();
            SqlDataAdapter objAdapter = new SqlDataAdapter(strSQL, myConnection);

            try
            {
                objAdapter.TableMappings.Add("Table", "tblRegion");
                objAdapter.TableMappings.Add("Table1", "tblCondition");

                objAdapter.Fill(dsItems);

                cboRegion.DataSource     = dsItems;
                cboRegion.DataMember     = "tblRegion";
                cboRegion.DataTextField  = "Region";
                cboRegion.DataValueField = "iD";
                cboRegion.DataBind();


                for (int i = 0; i < cboRegion.Items.Count; i++)
                {
                    switch (dsItems.Tables[0].Rows[i][2].ToString().Trim())
                    {
                    case "State":
                        cboRegion.Items[i].Attributes.Add("style", "color:#000000");
                        break;

                    case "Continent":
                        cboRegion.Items[i].Attributes.Add("style", "color:#999999");
                        break;

                    case "Country":
                        cboRegion.Items[i].Attributes.Add("style", "color:#666666");
                        break;
                    }
                }

                cboRegion.SelectedIndex = (int)0;

                radioConditionType.DataSource     = dsItems;
                radioConditionType.DataMember     = "tblCondition";
                radioConditionType.DataTextField  = "condition";
                radioConditionType.DataValueField = "iD";
                radioConditionType.DataBind();
                radioConditionType.SelectedIndex = (int)0;
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorRoutine(false, "Post.aspx: Error loading controls: " + ex.InnerException);
            }

            finally
            {
                myConnection.Close();
            }

            //hide for minisites
            if (hdnAdType.Value == "4")
            {
                pnlShip.Visible      = false;
                pnlCondition.Visible = false;
            }
        }
Exemple #41
0
        private void ddl_search_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            tbx_searchvalue.Text = "";
            tbx_searchvalue.Attributes["onfocus"] = "";
            tbx_searchvalue.ReadOnly = false;

            #region 条件选择
            switch (ddl_search.SelectedItem.Value)
            {
            case "客户名称": tbx_searchvalue.Visible = true; rbl_searchvalue.Visible = false; break;

            case "客户分类":
            {
                object[] array;
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = true;
                array = Enum.GetNames(typeof(UDS.Components.ClientType));
                for (int i = 0; i < array.Length; i++)
                {
                    switch (array[i].ToString())
                    {
                    case "terminal":
                        array[i] = "终端用户";
                        break;

                    case "channal":
                        array[i] = "渠道商";
                        break;

                    case "social":
                        array[i] = "社会关系";
                        break;

                    case "media":
                        array[i] = "媒体公关";
                        break;
                    }
                }
                rbl_searchvalue.DataSource = array;
                rbl_searchvalue.DataBind();
                break;
            }

            case "客户编号":
                tbx_searchvalue.Visible = true; rbl_searchvalue.Visible = false; break;

            case "联系人":
                tbx_searchvalue.Visible = true; rbl_searchvalue.Visible = false; break;

            case "电话":
                tbx_searchvalue.Visible = true; rbl_searchvalue.Visible = false; break;

            case "所处行业":
            {
                object[] array;
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = true;
                array = Enum.GetNames(typeof(UDS.Components.ClientTrade));
                for (int i = 0; i < array.Length; i++)
                {
                    switch (array[i].ToString())
                    {
                    case "realty":
                        array[i] = "房地产";
                        break;

                    case "IT":
                        array[i] = "IT";
                        break;

                    case "business":
                        array[i] = "商业贸易";
                        break;

                    case "telecom":
                        array[i] = "电信";
                        break;

                    case "post":
                        array[i] = "邮政通讯";
                        break;

                    case "refer":
                        array[i] = "咨询服务";
                        break;

                    case "travel":
                        array[i] = "旅游业";
                        break;

                    case "bus":
                        array[i] = "交通运输";
                        break;

                    case "stock":
                        array[i] = "金融证券";
                        break;

                    case "insurance":
                        array[i] = "保险";
                        break;

                    case "tax":
                        array[i] = "税务";
                        break;

                    case "make":
                        array[i] = "制造业";
                        break;

                    case "he":
                        array[i] = "家电";
                        break;

                    case "clothe":
                        array[i] = "服装";
                        break;

                    case "food":
                        array[i] = "食品";
                        break;

                    case "medicine":
                        array[i] = "医药";
                        break;

                    case "mechanism":
                        array[i] = "机械";
                        break;

                    case "auto":
                        array[i] = "汽车制造";
                        break;
                    }
                }
                rbl_searchvalue.DataSource = array;
                rbl_searchvalue.DataBind();
                break;
            }

            case "企业性质":
            {
                object[] array;
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = true;
                array = Enum.GetNames(typeof(UDS.Components.EnterpriseType));
                for (int i = 0; i < array.Length; i++)
                {
                    switch (array[i].ToString())
                    {
                    case "government":
                        array[i] = "政府";
                        break;

                    case "contry":
                        array[i] = "国营";
                        break;

                    case "oversea":
                        array[i] = "外资";
                        break;

                    case "stock":
                        array[i] = "上市公司";
                        break;

                    case "privateowned":
                        array[i] = "民营";
                        break;
                    }
                }
                rbl_searchvalue.DataSource = array;
                rbl_searchvalue.DataBind();
                break;
            }

            case "客户来源":
            {
                object[] array;
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = true;
                array = Enum.GetNames(typeof(UDS.Components.ClientSource));
                for (int i = 0; i < array.Length; i++)
                {
                    switch (array[i].ToString())
                    {
                    case "sellman":
                        array[i] = "销售主动联系";
                        break;

                    case "familiar":
                        array[i] = "以前认识";
                        break;

                    case "introduce":
                        array[i] = "熟人介绍";
                        break;

                    case "client":
                        array[i] = "客户主动联系";
                        break;
                    }
                }
                rbl_searchvalue.DataSource = array;
                rbl_searchvalue.DataBind();
                break;
            }

            case "添加日期":
                tbx_searchvalue.Visible = true;
                rbl_searchvalue.Visible = false;
                //tbx_searchvalue.ReadOnly = true;
                //tbx_searchvalue.Attributes["onfocus"] = "setday(this)";
                break;

            case "本周新增客户":
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = false;
                break;

            case "本月新增客户":
                tbx_searchvalue.Visible = false;
                rbl_searchvalue.Visible = false;
                break;

            default:
                tbx_searchvalue.Visible = true;
                rbl_searchvalue.Visible = false;
                break;
            }
            #endregion
        }
Exemple #42
0
        public void gPopulateRadioButtonList(RadioButtonList radlist, string strSQLQuery, string strTextField, string strValueField)
        {
            try
            {

                if (strSQLQuery != null || strSQLQuery != "")
                {

                    radlist.Items.Clear();

                    radlist.DataSource = objHelper.gReturnDataSet(CommandType.Text, strSQLQuery);

                    radlist.DataTextField = strTextField;
                    radlist.DataValueField = strValueField;

                    radlist.DataBind();
                }

            }
            catch
            {
                throw new Exception();
            }
        }