private void ShowGrid()
        {
            EGV.AutoGenerateColumns = false;
            DataControlFieldCollection dcfc = EGV.Columns;

            dcfc.Clear();
            TemplateField tf = new TemplateField();
            CheckBox      ch = new CheckBox();

            tf.HeaderText = "选择";



            BoundField bf1 = new BoundField();

            bf1.HeaderText                  = "ID";
            bf1.DataField                   = "ID";
            bf1.HeaderStyle.Width           = Unit.Percentage(5);
            bf1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf1.ItemStyle.HorizontalAlign   = HorizontalAlign.Center;
            dcfc.Add(bf1);


            DataTable dt = this.bfield.GetModelFieldListall(DataConverter.CLng(this.HdnModelID.Value));

            foreach (DataRow dr in dt.Rows)
            {
                if (DataConverter.CBool(dr["ShowList"].ToString()))
                {
                    ButtonField Link3 = new ButtonField();
                    Link3.ButtonType                = ButtonType.Link;
                    Link3.HeaderText                = dr["FieldAlias"].ToString();
                    Link3.DataTextField             = dr["FieldName"].ToString();
                    Link3.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                    Link3.ItemStyle.Width           = Unit.Percentage(10);
                    Link3.ItemStyle.CssClass        = "overflow:hidden;text-overflow:ellipsis";

                    dcfc.Add(Link3);
                }
            }
            ButtonField Link = new ButtonField();

            Link.ButtonType = ButtonType.Link;
            Link.HeaderText = "修改";
            Link.Text       = "修改";
            Link.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            Link.ItemStyle.Width           = Unit.Percentage(10);
            dcfc.Add(Link);


            ButtonField Link1 = new ButtonField();

            Link1.ButtonType                = ButtonType.Link;
            Link1.HeaderText                = "删除";
            Link1.Text                      = "删除";
            Link1.ItemStyle.Width           = Unit.Percentage(10);
            Link1.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            Link1.CausesValidation          = true;
            dcfc.Add(Link1);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates Default GridView Columns
        /// </summary>
        /// <param name="columns">Column collection</param>
        private void CreateGridViewColumns(DataControlFieldCollection columns)
        {
            this.Columns.Clear();
            TemplateField propertyColumn = new TemplateField();

            propertyColumn.HeaderText   = Resources.GlobalResource.FilterPropertyColumnHeader;
            propertyColumn.ItemTemplate = new CompiledBindableTemplateBuilder(BuildPropertyDropDown, null);
            columns.Add(propertyColumn);

            TemplateField operatorColumn = new TemplateField();

            operatorColumn.HeaderText   = Resources.GlobalResource.FilterOperatorColumnHeader;
            operatorColumn.ItemTemplate = new CompiledBindableTemplateBuilder(BuildOperatorDropDown, null);
            columns.Add(operatorColumn);

            TemplateField valueColumn = new TemplateField();

            valueColumn.HeaderText   = Resources.GlobalResource.FilterValueColumnHeader;
            valueColumn.ItemTemplate = new CompiledBindableTemplateBuilder(BuildValueTextBox, null);
            columns.Add(valueColumn);

            TemplateField conditionColumn = new TemplateField();

            conditionColumn.HeaderText   = Resources.GlobalResource.FilterConditionColumnHeader;
            conditionColumn.ItemTemplate = new CompiledBindableTemplateBuilder(BuildConditionDropDown, null);
            columns.Add(conditionColumn);

            TemplateField addRemoveColumn = new TemplateField();

            addRemoveColumn.ItemTemplate = new CompiledBindableTemplateBuilder(BuildAddRemoveButton, null);
            columns.Add(addRemoveColumn);
        }
Esempio n. 3
0
        public void DataControlFieldCollection_Insert()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();
            BoundField field = new BoundField();

            collection.Add(new BoundField());
            collection.Add(new BoundField());
            Assert.AreEqual(2, collection.Count, "CollectionCount");
            collection.Insert(0, field);
            int result = collection.IndexOf(field);

            Assert.AreEqual(0, result, "Insert");
        }
        public static void PrepareColumns(dynamic source, DataControlFieldCollection columns, Func<string, string> headerNameFormatter)
        {
            // if ViewState is enabled, the columns info will be persisted between requests and we only want to add the column 
            // the first time the grid is requested. 
            if (columns.Count == 0)
            {
                // at this point, the datasource must have been prepared and it must be a list
                var properties = source[0].GetType().GetProperties();
                foreach (var property in properties)
                {
                    var name = property.Name;

                    var field = new BoundField
                                    {
                                        DataField = name,
                                        HeaderText =
                                            headerNameFormatter == null
                                                ? SeperateNamesWithSpace(name)
                                                : headerNameFormatter(name),
                                        SortExpression = name,
                                        HtmlEncode = false
                                    };

                    if (property.PropertyType.Name == "DateTime")
                    {
                        field.DataFormatString = "{0:dd-MMM-yyyy}";
                    }

                    columns.Add(field);
                }
            }
        }
Esempio n. 5
0
        public void DataControlFieldCollection_Add()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.Add(new BoundField());
            Assert.AreEqual(1, collection.Count, "Add");
        }
Esempio n. 6
0
        public void DataControlFieldCollection_RemoveAt()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.Add(new BoundField());
            Assert.AreEqual(1, collection.Count, "CollectionCount");
            collection.RemoveAt(0);
            Assert.AreEqual(0, collection.Count, "RemoveAtIndex");
        }
Esempio n. 7
0
        public void DataControlFieldCollection_Contains()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();
            BoundField field = new BoundField();

            collection.Add(field);
            bool result = collection.Contains(field);

            Assert.AreEqual(true, result, "Contains");
        }
Esempio n. 8
0
        public void DataControlFieldCollection_Clone()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.Add(new BoundField());
            Assert.AreEqual(1, collection.Count, "Add");
            DataControlFieldCollection clone = collection.CloneFields();

            Assert.AreEqual(1, clone.Count, "Clone");
        }
Esempio n. 9
0
        public void DataControlFieldCollection_Remove()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();
            BoundField field = new BoundField();

            collection.Add(field);
            Assert.AreEqual(1, collection.Count, "CollectionCount");
            collection.Remove(null);
            Assert.AreEqual(1, collection.Count, "RemoveNotExistField");
            collection.Remove(field);
            Assert.AreEqual(0, collection.Count, "RemoveExistField");
        }
Esempio n. 10
0
        public void DataControlFieldCollection_IndexOf()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();
            BoundField field = new BoundField();
            int        result;

            result = collection.IndexOf(field);
            Assert.AreEqual(-1, result, "NotExistFieldIndex");
            collection.Add(field);
            result = collection.IndexOf(field);
            Assert.AreEqual(0, result, "ExistFieldIndex");
        }
Esempio n. 11
0
        public void DataControlFieldCollection_CopyTo()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.Add(new BoundField());
            DataControlField[] fields = new DataControlField[collection.Count];
            Array array = new DataControlField[collection.Count];

            collection.CopyTo(fields, 0);
            Assert.AreEqual(1, fields.Length, "CopyToDataControlField");
            collection.CopyTo(array, 0);
            Assert.AreEqual(1, array.Length, "CopyToArray");
        }
Esempio n. 12
0
        public void DataControlFieldCollection_GetEnumerator()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.Add(new BoundField());
            IEnumerator numerator = collection.GetEnumerator();

            Assert.IsNotNull(numerator, "GetEnumerator");
            if (!(numerator is IEnumerator))
            {
                Assert.Fail("IEnumerator not been created");
            }
        }
 public StandardGridViewTemplateGenerator(ListItemType type, DataControlFieldCollection columns = null)
 {
     Type    = type;
     Columns = columns;
     if (columns != null)
     {
         InitialColumns = new DataControlFieldCollection();
         // Save the columns initialy defined for the gridview
         foreach (DataControlField column in columns)
         {
             InitialColumns.Add(column);
         }
     }
 }
Esempio n. 14
0
        public void DataControlFieldCollection_FieldsChangedEvent()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.FieldsChanged += new EventHandler(collection_FieldsChanged);
            BoundField field = new BoundField();

            collection.Add(field);
            Assert.AreEqual(true, EventDone, "FieldsChangedEvenAdd");
            ResetEvent();
            collection.Clear();
            Assert.AreEqual(true, EventDone, "FieldsChangedEvenClear");
            ResetEvent();
            collection.Insert(0, field);
            Assert.AreEqual(true, EventDone, "FieldsChangedEvenInsert");
            ResetEvent();
            collection.Remove(field);
            Assert.AreEqual(true, EventDone, "FieldsChangedEvenRemove");
        }
        private DataTable ShowGrid()
        {
            M_CommonData mc = cbll.GetCommonData(DataConverter.CLng(Request.QueryString["Id"]));
            int          i  = mc.ModelID;
            DataTable    dt = this.mfbll.GetModelFieldList(DataConverter.CLng(i));

            DetailsView1.AutoGenerateRows = false;
            DataControlFieldCollection dcfc = DetailsView1.Fields;

            dcfc.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                BoundField bf = new BoundField();
                bf.HeaderText                  = dr["FieldAlias"].ToString();
                bf.DataField                   = dr["FieldName"].ToString();
                bf.HeaderStyle.Width           = Unit.Percentage(15);
                bf.HeaderStyle.CssClass        = "tdbgleft";
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                bf.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bf.HtmlEncode                  = false;
                dcfc.Add(bf);
            }
            return(dt);
        }
Esempio n. 16
0
 public override DataControlFieldCollection GetColumns()
 {
     if (columns == null)
     {
         columns = new DataControlFieldCollection
         {
             Fields.Create(ConstantDict.GetColumnTitle("Statusicon"), typeof(Icon), 5, HorizontalAlign.Center)
         };
         //columns.Add(ExtFields.GetRatingField());
         //columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Stricon"), typeof(CommandColumn), Cmds, 5, HorizontalAlign.Center));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Id"), typeof(string), 10, HorizontalAlign.Left).SetEditable(true));
         //columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Tahun"), typeof(string), 10, HorizontalAlign.Left).SetEditable(true));
         //columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Satker"), typeof(string), 10, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdpemda"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kddata"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdbab"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmbab"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdkel"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmkel"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdjns"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmjns"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdobj"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmobj"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdrnc"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmrnc"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdor1"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmor1"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdor2"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmor2"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdor3"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmor3"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdor4"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmor4"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdor5"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmor5"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdpr"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmpr"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdkeg"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmkeg"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdfung1"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmfung1"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdfung2"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmfung2"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Kdfung3"), typeof(string), 30, HorizontalAlign.Left).SetEditable(true));
         columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nmfung3"), typeof(string), 50, HorizontalAlign.Left).SetEditable(true));
         //columns.Add(Fields.Create(ConstantDict.GetColumnTitle("Nilai"), typeof(decimal), 15, HorizontalAlign.Right));
     }
     return(columns);
 }
        private void ShowGrid()
        {
            DataTable dt = this.bfield.GetModelFieldListall(DataConverter.CLng(this.HdnModelID.Value));

            Egv.AutoGenerateColumns = false;
            DataControlFieldCollection dcfc = Egv.Columns;

            dcfc.Clear();


            TemplateField tf = new TemplateField();

            CheckBox ch = new CheckBox();

            tf.HeaderText = "选择";
            tf.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            tf.ItemStyle.Width           = Unit.Percentage(10);
            tf.ItemTemplate = new GenericItem();
            //Egv.Columns.Add(tf);
            dcfc.Add(tf);

            BoundField bf1 = new BoundField();

            bf1.HeaderText                  = "ID";
            bf1.DataField                   = "ID";
            bf1.HeaderStyle.Width           = Unit.Percentage(5);
            bf1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf1.ItemStyle.HorizontalAlign   = HorizontalAlign.Center;
            dcfc.Add(bf1);

            foreach (DataRow dr in dt.Rows)
            {
                if (DataConverter.CBool(dr["ShowList"].ToString()))
                {
                    BoundField bf = new BoundField();
                    bf.HeaderText                  = dr["FieldAlias"].ToString();
                    bf.DataField                   = dr["FieldName"].ToString();
                    bf.HeaderStyle.Width           = Unit.Percentage(DataConverter.CDouble(dr["ShowWidth"]));
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                    bf.ItemStyle.HorizontalAlign   = HorizontalAlign.Center;
                    dcfc.Add(bf);
                }
            }



            ButtonField Link = new ButtonField();

            Link.ButtonType = ButtonType.Link;
            Link.HeaderText = "还原";
            Link.Text       = "还原";
            Link.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            Link.ItemStyle.Width           = Unit.Percentage(10);
            dcfc.Add(Link);


            ButtonField Link1 = new ButtonField();

            Link1.ButtonType                = ButtonType.Link;
            Link1.HeaderText                = "删除";
            Link1.Text                      = "删除";
            Link1.ItemStyle.Width           = Unit.Percentage(10);
            Link1.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            Link1.CausesValidation          = true;
            dcfc.Add(Link1);

            if (dt != null)
            {
                dt.Dispose();
            }
            if (dt != null)
            {
                dt.Dispose();
            }
        }
Esempio n. 18
0
        private DataTable ShowGrid()
        {
            DataTable dt = this.bfield.GetModelFieldList(DataConverter.CLng(this.HdnModelID.Value));

            DetailsView1.AutoGenerateRows = false;
            DataControlFieldCollection dcfc = DetailsView1.Fields;


            dcfc.Clear();


            BoundField bf2 = new BoundField();

            bf2.HeaderText                  = "ID";
            bf2.DataField                   = "ID";
            bf2.HeaderStyle.Width           = Unit.Percentage(15);
            bf2.HeaderStyle.CssClass        = "tdbgleft";
            bf2.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf2.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;

            dcfc.Add(bf2);

            BoundField bf5 = new BoundField();

            bf5.HeaderText                  = "用户名";
            bf5.DataField                   = "PubUserName";
            bf5.HeaderStyle.CssClass        = "tdbgleft";
            bf5.HeaderStyle.Width           = Unit.Percentage(15);
            bf5.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf5.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            dcfc.Add(bf5);

            BoundField bf1 = new BoundField();

            bf1.HeaderText                  = "标题";
            bf1.DataField                   = "PubTitle";
            bf1.HeaderStyle.CssClass        = "tdbgleft";
            bf1.HeaderStyle.Width           = Unit.Percentage(15);
            bf1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf1.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            bf1.HtmlEncode                  = false;
            dcfc.Add(bf1);

            BoundField bfa = new BoundField();

            bfa.HeaderText                  = "内容";
            bfa.DataField                   = "PubContent";
            bfa.HeaderStyle.CssClass        = "tdbgleft";
            bfa.HeaderStyle.Width           = Unit.Percentage(15);
            bfa.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bfa.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            bfa.HtmlEncode                  = false;
            dcfc.Add(bfa);

            BoundField bf3 = new BoundField();

            bf3.HeaderText                  = "IP地址";
            bf3.DataField                   = "PubIP";
            bf3.HeaderStyle.CssClass        = "tdbgleft";
            bf3.HeaderStyle.Width           = Unit.Percentage(15);
            bf3.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf3.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            bf3.HtmlEncode                  = false;
            dcfc.Add(bf3);

            BoundField bf4 = new BoundField();

            bf4.HeaderText                  = "添加时间";
            bf4.DataField                   = "PubAddTime";
            bf4.HeaderStyle.CssClass        = "tdbgleft";
            bf4.HeaderStyle.Width           = Unit.Percentage(15);
            bf4.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf4.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            bf4.HtmlEncode                  = false;
            dcfc.Add(bf4);


            foreach (DataRow dr in dt.Rows)
            {
                BoundField bf = new BoundField();
                bf.HeaderText                  = dr["FieldAlias"].ToString();
                bf.DataField                   = dr["FieldName"].ToString();
                bf.HeaderStyle.Width           = Unit.Percentage(15);
                bf.HeaderStyle.CssClass        = "tdbgleft";
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                bf.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bf.HtmlEncode                  = false;
                dcfc.Add(bf);
            }
            return(dt);
        }