Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        private static DataControlField CreateBoundField(GridViewColumnConfig cfg)
        {
            BoundField bf = new BoundField();

            bf.DataField        = cfg.DataTextField;
            bf.DataFormatString = cfg.DataFormatString;
            return(bf);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        private static DataControlField CreateHyperLinkField(GridViewColumnConfig cfg)
        {
            //throw new NotImplementedException();
            HyperLinkField hlf = new HyperLinkField();

            hlf.HeaderText                  = cfg.HeaderText;
            hlf.Text                        = cfg.HyperLinkText;
            hlf.DataNavigateUrlFields       = cfg.DataNavigateUrlFields;
            hlf.DataNavigateUrlFormatString = cfg.DataNavigateUrlFormatString;
            return(hlf);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        private static DataControlField CreateTemplateField(GridViewColumnConfig cfg)
        {
            TemplateField field = new TemplateField();

            // 170 = 160(textbox width) + 10
            //
            field.ItemStyle.Width = 170;
            field.HeaderText      = cfg.HeaderText;
            field.ItemTemplate    = cfg.ItemTemplate;

            return(field);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        private static DataControlField CreateCommandField(GridViewColumnConfig cfg)
        {
            CommandField cmd = new CommandField();

            if (cfg.ShowInsertButton)
            {
                cmd.ShowInsertButton = true;
            }
            if (cfg.ShowEditButton)
            {
                cmd.ShowEditButton = true;
            }
            if (cfg.ShowDeleteButton)
            {
                cmd.ShowDeleteButton = true;
            }
            return(cmd);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        static public DataControlField Create(GridViewColumnConfig cfg)
        {
            if (cfg == null)
            {
                throw new ArgumentNullException("cfg");
            }

            DataControlField dcf = null;

            switch (cfg.GridViewColumnTypeEnum)
            {
            case GridViewColumnTypeEnum.BoundField:
                dcf = CreateBoundField(cfg);
                break;

            case GridViewColumnTypeEnum.HyperLinkField:
                dcf = CreateHyperLinkField(cfg);
                break;

            case GridViewColumnTypeEnum.CommandField:
                dcf = CreateCommandField(cfg);
                break;

            case GridViewColumnTypeEnum.TemplateField:
                dcf = CreateTemplateField(cfg);
                break;
            }

            //DataControlField dcf = Create(cfg.GridViewColumnTypeEnum);
            //dcf.Visible = cfg.Visible;
            //dcf.HeaderText = cfg.HeaderText;
            //dcf.SortExpression = cfg.SortExpression;


            dcf.HeaderText     = cfg.HeaderText;
            dcf.Visible        = cfg.Visible;
            dcf.SortExpression = cfg.SortExpression;
            return(dcf);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private GridViewConfig GetGridViewConfig()
        {
            GridViewConfig cfg = new GridViewConfig();
            cfg.AllowSorting = true;
            cfg.Caption = "Amount caption";

            //GridViewColumnConfig c1 = new GridViewColumnConfig();
            //c1.DataTextField = "Amount";
            //c1.HeaderText = "h-Amount";
            //c1.SortExpression = "Amount";
            //c1.GridViewColumnTypeEnum = GridViewColumnTypeEnum.BoundField;
            cfg.GridViewColumnConfigCollection.AddBoundField("a", "Amount");

            GridViewColumnConfig c2 = new GridViewColumnConfig();
            c2.DataTextField = "WaterUserName";
            c2.HeaderText = "名称";
            c2.SortExpression = "WaterUserName";
            cfg.GridViewColumnConfigCollection.Add(c2);

            return cfg;
        }