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);
        }
Example #2
0
        public void DataControlFieldCollection_Clear()
        {
            DataControlFieldCollection collection = new DataControlFieldCollection();

            collection.Add(new BoundField());
            Assert.AreEqual(1, collection.Count, "Add");
            collection.Clear();
            Assert.AreEqual(0, collection.Count, "Clear");
        }
Example #3
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);
        }
        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();
            }
        }
Example #6
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);
        }