コード例 #1
0
        /// <summary>
        /// 控件绑定模型配置
        /// </summary>
        /// <param name="page"></param>
        /// <param name="modelName">实现IPFConfigMapper的类中定义</param>
        /// <param name="list"></param>
        public static void BindModel(string modelName, List <ModelBindConfig> list)
        {
            var modelConfig = PFDataHelper.GetMultiModelConfig(modelName);

            foreach (var i in list)
            {
                PFModelConfig config = null;
                if (modelConfig != null)
                {
                    config = modelConfig[i.GetPropertyName()];
                }
                if (i.GetComponent() is System.Web.UI.WebControls.Label)
                {
                    System.Web.UI.WebControls.Label tmpControl = (System.Web.UI.WebControls.Label)i.GetComponent();
                    LabelBind(tmpControl, config);
                }
                else if (i.GetComponent() is System.Web.UI.WebControls.TextBox)
                {
                    System.Web.UI.WebControls.TextBox tmpControl = (System.Web.UI.WebControls.TextBox)i.GetComponent();
                    BindValidator(tmpControl, config, i.GetValidator());
                    LabelBind(i.GetLabel(), config);
                    TextBoxBind(tmpControl, config);
                }
                else if (i.GetComponent() is System.Web.UI.WebControls.DropDownList)
                {
                    System.Web.UI.WebControls.DropDownList tmpControl = (System.Web.UI.WebControls.DropDownList)i.GetComponent();
                    BindValidator(tmpControl, config, i.GetValidator());
                    LabelBind(i.GetLabel(), config);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 控件绑定模型配置
        /// </summary>
        /// <param name="page"></param>
        /// <param name="modelName">实现IPFConfigMapper的类中定义</param>
        /// <param name="list"></param>
        public static void GridBindModel(DataGrid grid, string modelName)
        {
            var modelConfig = PFDataHelper.GetMultiModelConfig(modelName);

            if (modelConfig != null)
            {
                if (grid.Columns != null)
                {
                    foreach (DataGridColumn c in grid.Columns)
                    {
                        if (c is BoundColumn)
                        {
                            BoundColumn   tc     = c as BoundColumn;
                            PFModelConfig config = null;
                            if (modelConfig != null)
                            {
                                config = modelConfig[tc.DataField];
                            }
                            if (config != null && (PFDataHelper.StringIsNullOrWhiteSpace(tc.HeaderText) || tc.HeaderText == config.FieldName))
                            {
                                tc.HeaderText = config.FieldText;
                            }
                        }
                        else if (c is TemplateColumn)
                        {
                            TemplateColumn tc     = c as TemplateColumn;
                            PFModelConfig  config = null;
                            if (modelConfig != null)
                            {
                                config = modelConfig[tc.HeaderText];
                            }
                            if (config != null && (PFDataHelper.StringIsNullOrWhiteSpace(tc.HeaderText) || tc.HeaderText == config.FieldName))
                            {
                                tc.HeaderText = config.FieldText;
                            }
                        }
                    }
                }
            }
        }