Exemplo n.º 1
0
 public static void SetDataSourceAndBind(object control, object dataSource)
 {
     if (control is DataBoundControl)
     {
         DataBoundControl bindable = (DataBoundControl)control;
         bindable.DataSource = dataSource;
         bindable.DataBind();
     }
     else if (control is BaseDataList)
     {
         BaseDataList bindable = (BaseDataList)control;
         bindable.DataSource = dataSource;
         bindable.DataBind();
     }
     else if (control is Repeater)
     {
         Repeater bindable = (Repeater)control;
         bindable.DataSource = dataSource;
         bindable.DataBind();
     }
     else
     {
         throw new NotSupportedException(control.GetType().Name + " is not a supported data control");
     }
 }
        /// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.LoadDataSourceFields"]/*' />
        /// <devdoc>
        /// </devdoc>
        private void LoadDataSourceFields()
        {
            EnterLoadingMode();

            dataKeyFieldCombo.SelectedIndex = -1;
            dataKeyFieldCombo.Items.Clear();
            dataKeyFieldCombo.EnsureNotSetItem();

            if (currentDataSource != null)
            {
                PropertyDescriptorCollection fields = currentDataSource.Fields;

                if (fields != null)
                {
                    IEnumerator fieldEnum = fields.GetEnumerator();
                    while (fieldEnum.MoveNext())
                    {
                        PropertyDescriptor fieldDesc = (PropertyDescriptor)fieldEnum.Current;

                        if (BaseDataList.IsBindableType(fieldDesc.PropertyType))
                        {
                            dataKeyFieldCombo.AddItem(fieldDesc.Name);
                        }
                    }
                }
            }

            ExitLoadingMode();
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if ((base.Component != null) && (base.Component.Site != null))
         {
             if (base.RootDesigner != null)
             {
                 base.RootDesigner.LoadComplete -= new EventHandler(this.OnDesignerLoadComplete);
             }
             IComponentChangeService service = (IComponentChangeService)base.Component.Site.GetService(typeof(IComponentChangeService));
             if (service != null)
             {
                 service.ComponentAdded    -= new ComponentEventHandler(this.OnComponentAdded);
                 service.ComponentRemoving -= new ComponentEventHandler(this.OnComponentRemoving);
                 service.ComponentRemoved  -= new ComponentEventHandler(this.OnComponentRemoved);
                 service.ComponentChanged  -= new ComponentChangedEventHandler(this.OnAnyComponentChanged);
             }
         }
         this.bdl = null;
         if (this._dataSourceDesigner != null)
         {
             this._dataSourceDesigner.DataSourceChanged -= new EventHandler(this.DataSourceChanged);
             this._dataSourceDesigner.SchemaRefreshed   -= new EventHandler(this.SchemaRefreshed);
             this._dataSourceDesigner = null;
         }
     }
     base.Dispose(disposing);
 }
Exemplo n.º 4
0
        /// <summary>
        /// </summary>
        private void LoadDataSourceFields()
        {
            using (new LoadingModeResource(this))
            {
                _dataTextFieldCombo.SelectedIndex = -1;
                _dataTextFieldCombo.Items.Clear();
                _dataTextFieldCombo.EnsureNotSetItem();

                _dataValueFieldCombo.SelectedIndex = -1;
                _dataValueFieldCombo.Items.Clear();
                _dataValueFieldCombo.EnsureNotSetItem();

                if (_currentDataSource != null)
                {
                    PropertyDescriptorCollection fields = _currentDataSource.Fields;

                    if (fields != null)
                    {
                        IEnumerator fieldEnum = fields.GetEnumerator();
                        while (fieldEnum.MoveNext())
                        {
                            PropertyDescriptor fieldDesc = (PropertyDescriptor)fieldEnum.Current;

                            if (BaseDataList.IsBindableType(fieldDesc.PropertyType))
                            {
                                _dataTextFieldCombo.AddItem(fieldDesc.Name);
                                _dataValueFieldCombo.AddItem(fieldDesc.Name);
                            }
                        }
                    }
                }
            }
        }
        public override void Initialize(IComponent component)
        {
            ControlDesigner.VerifyInitializeArgument(component, typeof(BaseDataList));
            this.bdl = (BaseDataList)component;
            base.Initialize(component);
            base.SetViewFlags(ViewFlags.DesignTimeHtmlRequiresLoadComplete, true);
            if (base.RootDesigner != null)
            {
                if (base.RootDesigner.IsLoading)
                {
                    base.RootDesigner.LoadComplete += new EventHandler(this.OnDesignerLoadComplete);
                }
                else
                {
                    this.OnDesignerLoadComplete(null, EventArgs.Empty);
                }
            }
            IComponentChangeService service = (IComponentChangeService)component.Site.GetService(typeof(IComponentChangeService));

            if (service != null)
            {
                service.ComponentAdded    += new ComponentEventHandler(this.OnComponentAdded);
                service.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemoving);
                service.ComponentRemoved  += new ComponentEventHandler(this.OnComponentRemoved);
                service.ComponentChanged  += new ComponentChangedEventHandler(this.OnAnyComponentChanged);
            }
        }
            //private static Dictionary<Type, Action<object, object>> map;

            //static DataBindingHelper()
            //{
            //    map = new Dictionary<Type, Action<object, object>>();
            //    map.Add(
            //        typeof(DataBoundControl),
            //            (control, data) =>
            //            {
            //                ((DataBoundControl)control).DataSource = data;
            //                ((DataBoundControl)control).DataBind();
            //            });
            //    map.Add(typeof(BaseDataList),
            //            (control, data) =>
            //            {
            //                ((BaseDataList)control).DataSource = data;
            //                ((BaseDataList)control).DataBind();
            //            });

            //}
            public static void SetDataSourceAndBind(object control, object dataSource)
            {
                if (control is DataBoundControl)
                {
                    DataBoundControl bindable = (DataBoundControl)control;
                    bindable.DataSource = dataSource;
                    bindable.DataBind();
                }
                else if (control is BaseDataList)
                {
                    BaseDataList bindable = (BaseDataList)control;
                    bindable.DataSource = dataSource;
                    bindable.DataBind();
                }
                else if (control is Repeater)
                {
                    Repeater bindable = (Repeater)control;
                    bindable.DataSource = dataSource;
                    bindable.DataBind();
                }
                else
                {
                    throw new NotSupportedException(control.GetType().Name + " is not a supported data control");
                }

                //foreach (var type in map.Keys)
                //{
                //    if (type.IsAssignableFrom(control.GetType()))
                //    {
                //        map[type](control, dataSource);
                //        return;
                //    }
                //}
                //throw new NotSupportedException(control.GetType().Name + " is not a supported data control");
            }
        /// <include file='doc\BaseDataListDesigner.uex' path='docs/doc[@for="BaseDataListDesigner.Initialize"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Initializes the designer with the DataGrid control that this instance
        ///       of the designer is associated with.
        ///    </para>
        /// </devdoc>
        public override void Initialize(IComponent component)
        {
            Debug.Assert(component is BaseDataList,
                         "BaseDataListDesigner::Initialize - Invalid BaseDataList Control");

            bdl = (BaseDataList)component;
            base.Initialize(component);
        }
Exemplo n.º 8
0
        protected void GHTBuildSampleDataList(BaseDataList ctl)
        {
            DataList lst = (DataList)ctl;

            lst.ItemTemplate = new MyItemTemplate();
            lst.DataSource   = GHTGetSampleDataSource();
            lst.DataBind();
        }
        /// <include file='doc\BaseDataListDesigner.uex' path='docs/doc[@for="BaseDataListDesigner.Dispose"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Disposes of the resources (other than memory) used by
        ///       the <see cref='System.Web.UI.Design.WebControls.BaseDataListDesigner'/>.
        ///    </para>
        /// </devdoc>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                bdl = null;
            }

            base.Dispose(disposing);
        }
Exemplo n.º 10
0
        private static void Fill <U, T>(U dataControl, T data)
            where U : Control
            where T : class
        {
            if (dataControl.IsNull())
            {
                return;
            }

            if (data.IsNull())
            {
                Clear <U>(dataControl);
                return;
            }

            if (SObject.IsTypeNotInList <U>(typeof(BaseDataList), typeof(Repeater), typeof(BaseDataBoundControl)))
            {
                throw new InvalidCastException("Control parameter is not valid, you are only alowed to use: BaseDataList, Repeater and BaseDataBoundControl");
            }

            if (SObject.IsTypeNotInList <T>(typeof(IListSource), typeof(IEnumerable), typeof(IDataSource)))
            {
                throw new InvalidCastException("Data parameter is not valid, you are only alowed to use: IDataSource, IEnumerable and IListSource");
            }

            try
            {
                dataControl.GetType().GetProperty("DataSource").SetValue(dataControl, data);
                dataControl.GetType().GetMethod("DataBind").Invoke(dataControl, null);
            }
            catch (Exception)
            {
                if (dataControl is BaseDataList)
                {
                    BaseDataList dl = dataControl as BaseDataList;
                    dl.DataSource = data;
                    dl.DataBind();
                }
                else if (dataControl is Repeater)
                {
                    Repeater rptr = dataControl as Repeater;
                    rptr.DataSource = data;
                    rptr.DataBind();
                }
                else if (dataControl is BaseDataBoundControl)
                {
                    BaseDataBoundControl grv = dataControl as BaseDataBoundControl;
                    grv.DataSource = data;
                    grv.DataBind();
                }
            }

            if (data is DbDataReader)
            {
                data.GetType().GetMethod("Close").Invoke(data, null);
            }
        }
Exemplo n.º 11
0
 private void TestControls(BaseDataList ctl)
 {
     this.GHTSubTestBegin("BaseDataList_" + ctl.GetType().Name + "_Controls1");
     base.GHTActiveSubTest.Controls.Add(ctl);
     try
     {
         ControlCollection collection1 = ctl.Controls;
     }
     catch (Exception exception2)
     {
         this.GHTSubTestUnexpectedExceptionCaught(exception2);
     }
     this.GHTSubTestEnd();
 }
Exemplo n.º 12
0
 private void TestCellSpacing(BaseDataList ctl, GHTSubTest SubTest, int CellSpacing)
 {
     try
     {
         base.GHTActiveSubTest = SubTest;
         ctl.DataSource        = GHTDataListBase.GHTGetSampleDataSource();
         ctl.DataBind();
         ctl.CellSpacing = CellSpacing;
     }
     catch (Exception exception2)
     {
         this.GHTSubTestUnexpectedExceptionCaught(exception2);
     }
 }
Exemplo n.º 13
0
        protected void GHTBuildUnboundSampleDataGrid(BaseDataList ctl)
        {
            DataGrid    grid = (DataGrid)ctl;
            BoundColumn col  = new BoundColumn();

            col.DataField = "colA";
            grid.Columns.Add(col);
            col           = new BoundColumn();
            col.DataField = "colB";
            grid.Columns.Add(col);
            col           = new BoundColumn();
            col.DataField = "colC";
            grid.Columns.Add(col);
            grid.AutoGenerateColumns = false;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Процедура заполнения любого списочного контрола.
        /// </summary>
        /// <param name="list">Название списочного контрола</param>
        /// <param name="cmd">SQL-команда заполнения списка</param>
        /// <param name="parameters">Набор SQL-параметров</param>
        public static void BindList(Control list, SqlCommand cmd, params SqlParameter[] parameters)
        {
            if (cmd.Connection == null)
            {
                cmd.Connection = CreateConnection();
            }

            cmd.Parameters.AddRange(parameters);

            using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
            {
                DataTable table = new DataTable();
                sda.Fill(table);

                if (list is ListControl)
                {
                    ListControl listControl = list as ListControl;
                    listControl.DataSource     = table;
                    listControl.DataValueField = "OptionValue";
                    listControl.DataTextField  = "OptionText";
                    listControl.DataBind();
                }
                else if (list is BaseDataList)
                {
                    BaseDataList baseDataList = list as BaseDataList;
                    baseDataList.DataSource = table;
                    baseDataList.DataBind();
                }
                else if (list is Repeater)
                {
                    Repeater repeater = list as Repeater;
                    repeater.DataSource = table;
                    repeater.DataBind();
                }
                else if (list is System.Web.UI.HtmlControls.HtmlSelect)
                {
                    System.Web.UI.HtmlControls.HtmlSelect listControl = list as System.Web.UI.HtmlControls.HtmlSelect;
                    listControl.DataSource     = table;
                    listControl.DataValueField = "OptionValue";
                    listControl.DataTextField  = "OptionText";
                    listControl.DataBind();
                }
            }
        }
Exemplo n.º 15
0
 private void TestCellSpacingError(BaseDataList ctl, GHTSubTest SubTest, int CellSpacing)
 {
     try
     {
         base.GHTActiveSubTest = SubTest;
         ctl.DataBind();
         ctl.DataSource  = GHTDataListBase.GHTGetSampleDataSource();
         ctl.CellSpacing = CellSpacing;
         this.GHTSubTestExpectedExceptionNotCaught("ArgumentException");
     }
     catch (ArgumentException exception3)
     {
         this.GHTSubTestExpectedExceptionCaught(exception3);
     }
     catch (Exception exception4)
     {
         this.GHTSubTestUnexpectedExceptionCaught(exception4);
     }
 }
Exemplo n.º 16
0
 private void Test(Type CtlType, BaseDataList_ctor_.BuildDataListControl CtlBuilder)
 {
     try
     {
         this.GHTSubTestBegin("BaseDataList_" + CtlType.Name + "_DataBind1");
         BaseDataList list1 = (BaseDataList)this.GHTElementClone(CtlType);
         base.GHTActiveSubTest.Controls.Add(list1);
         CtlBuilder(list1);
         list1.DataSource = GHTDataListBase.GHTGetSampleDataSource();
         list1.DataBind();
         list1.Caption             = "Caption Text";
         list1.CaptionAlign        = TableCaptionAlign.Right;
         list1.UseAccessibleHeader = true;
     }
     catch (Exception exception2)
     {
         this.GHTSubTestUnexpectedExceptionCaught(exception2);
     }
 }
Exemplo n.º 17
0
        /// <include file='doc\BordersPage.uex' path='docs/doc[@for="BordersPage.LoadComponent"]/*' />
        /// <devdoc>
        ///   Loads the component into the page.
        /// </devdoc>
        protected override void LoadComponent()
        {
            InitPage();

            BaseDataList bdl = (BaseDataList)GetBaseControl();

            int cellPadding = bdl.CellPadding;

            if (cellPadding != -1)
            {
                cellPaddingEdit.Text = (cellPadding).ToString();
            }
            int cellSpacing = bdl.CellSpacing;

            if (cellSpacing != -1)
            {
                cellSpacingEdit.Text = (cellSpacing).ToString();
            }

            switch (bdl.GridLines)
            {
            case GridLines.None:
                gridLinesCombo.SelectedIndex = IDX_GRID_NEITHER;
                break;

            case GridLines.Horizontal:
                gridLinesCombo.SelectedIndex = IDX_GRID_HORIZONTAL;
                break;

            case GridLines.Vertical:
                gridLinesCombo.SelectedIndex = IDX_GRID_VERTICAL;
                break;

            case GridLines.Both:
                gridLinesCombo.SelectedIndex = IDX_GRID_BOTH;
                break;
            }

            borderColorCombo.Color = ColorTranslator.ToHtml(bdl.BorderColor);
            borderWidthUnit.Value  = bdl.BorderWidth.ToString();
        }
Exemplo n.º 18
0
        private void Test(Type CtlType)
        {
            Type type1;
            bool flag1;

            try
            {
                this.GHTSubTestBegin("BaseDataList_" + CtlType.Name + "_IsBindableType1");
                Type[] typeArray1 = this.marrBindaleType;
                for (int num1 = 0; num1 < typeArray1.Length; num1++)
                {
                    type1 = typeArray1[num1];
                    flag1 = BaseDataList.IsBindableType(type1);
                    this.GHTSubTestAddResult(type1.ToString() + " is bindable = " + flag1.ToString());
                }
            }
            catch (Exception exception4)
            {
                this.GHTSubTestUnexpectedExceptionCaught(exception4);
            }
            this.GHTSubTestEnd();
            try
            {
                this.GHTSubTestBegin("BaseDataList_" + CtlType.Name + "_IsBindableType2");
                type1 = null;
                flag1 = BaseDataList.IsBindableType(null);
                this.GHTSubTestAddResult("Nothing is bindable = " + flag1.ToString());
                this.GHTSubTestExpectedExceptionNotCaught("NullReferenceException");
            }
            catch (NullReferenceException exception5)
            {
                this.GHTSubTestExpectedExceptionCaught(exception5);
                return;
            }
            catch (Exception exception6)
            {
                this.GHTSubTestUnexpectedExceptionCaught(exception6);
                return;
            }
        }
Exemplo n.º 19
0
 private void Test(Type CtlType, BaseDataList_DataKeys.BuildDataListControl CtlBuilder)
 {
     try
     {
         string      text1       = "";
         IEnumerator enumerator1 = null;
         this.GHTSubTestBegin("BaseDataList_" + CtlType.Name + "_DataKeys1");
         BaseDataList list1 = (BaseDataList)this.GHTElementClone(CtlType);
         list1.DataKeyField = "colA";
         CtlBuilder(list1);
         base.GHTActiveSubTest.Controls.Add(list1);
         try
         {
             enumerator1 = list1.DataKeys.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 string text2 = (string)(enumerator1.Current);
                 text1 = text1 + text2 + "-";
             }
         }
         finally
         {
             if (enumerator1 is IDisposable)
             {
                 ((IDisposable)enumerator1).Dispose();
             }
         }
         this.GHTSubTestAddResult("DataKeys = " + text1);
     }
     catch (Exception exception2)
     {
         // ProjectData.SetProjectError(exception2);
         Exception exception1 = exception2;
         this.GHTSubTestUnexpectedExceptionCaught(exception1);
         // ProjectData.ClearProjectError();
     }
     this.GHTSubTestEnd();
 }
        protected override void LoadComponent()
        {
            this.InitPage();
            BaseDataList baseControl = base.GetBaseControl();
            int          cellPadding = baseControl.CellPadding;

            if (cellPadding != -1)
            {
                this.cellPaddingEdit.Text = cellPadding.ToString(NumberFormatInfo.CurrentInfo);
            }
            int cellSpacing = baseControl.CellSpacing;

            if (cellSpacing != -1)
            {
                this.cellSpacingEdit.Text = cellSpacing.ToString(NumberFormatInfo.CurrentInfo);
            }
            switch (baseControl.GridLines)
            {
            case GridLines.None:
                this.gridLinesCombo.SelectedIndex = 3;
                break;

            case GridLines.Horizontal:
                this.gridLinesCombo.SelectedIndex = 0;
                break;

            case GridLines.Vertical:
                this.gridLinesCombo.SelectedIndex = 1;
                break;

            case GridLines.Both:
                this.gridLinesCombo.SelectedIndex = 2;
                break;
            }
            this.borderColorCombo.Color = ColorTranslator.ToHtml(baseControl.BorderColor);
            this.borderWidthUnit.Value  = baseControl.BorderWidth.ToString(CultureInfo.CurrentCulture);
        }
Exemplo n.º 21
0
        private static void Clear <T>(T dataControl)
            where T : Control
        {
            if (SObject.IsTypeNotInList <T>(typeof(BaseDataList), typeof(Repeater), typeof(BaseDataBoundControl)))
            {
                throw new InvalidCastException("Control parameter is not valid, you are only alowed to use: BaseDataList, Repeater and BaseDataBoundControl");
            }

            object data = null;

            try
            {
                dataControl.GetType().GetProperty("DataSource").SetValue(dataControl, data);
                dataControl.GetType().GetMethod("DataBind").Invoke(dataControl, null);
            }
            catch (Exception)
            {
                if (dataControl is BaseDataList)
                {
                    BaseDataList dl = dataControl as BaseDataList;
                    dl.DataSource = data;
                    dl.DataBind();
                }
                else if (dataControl is Repeater)
                {
                    Repeater rptr = dataControl as Repeater;
                    rptr.DataSource = data;
                    rptr.DataBind();
                }
                else if (dataControl is BaseDataBoundControl)
                {
                    BaseDataBoundControl grv = dataControl as BaseDataBoundControl;
                    grv.DataSource = data;
                    grv.DataBind();
                }
            }
        }
Exemplo n.º 22
0
 public void IsBindableType()
 {
     // documented
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(bool)), "bool");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(byte)), "byte");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(sbyte)), "sbyte");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(short)), "short");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(ushort)), "ushort");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(int)), "int");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(uint)), "uint");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(long)), "long");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(ulong)), "ulong");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(char)), "char");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(double)), "double");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(float)), "float");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(DateTime)), "DateTime");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(decimal)), "decimal");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(string)), "string");
     // and others (from TypeCode)
     Assert.IsFalse(BaseDataList.IsBindableType(typeof(object)), "object");
     Assert.IsFalse(BaseDataList.IsBindableType(typeof(DBNull)), "DBNull");
     // and junk
     Assert.IsFalse(BaseDataList.IsBindableType(this.GetType()), "this");
 }
Exemplo n.º 23
0
 /// <summary>
 /// Bind data to DataList Control
 /// </summary>
 /// <param name="dataControl"></param>
 /// <param name="dataSource"></param>
 public void BindDataControl(BaseDataList dataControl, object dataSource)
 {
     dataControl.DataSource = dataSource;
     dataControl.DataBind();
 }
Exemplo n.º 24
0
        private void BindData()
        {
            // 确保控件存在且为列表控件
            _controlToPaginate = Page.FindControl(DataContainer);
            if (_controlToPaginate == null)
            {
                return;
            }
            if (!(_controlToPaginate is BaseDataList || _controlToPaginate is ListControl || _controlToPaginate is Repeater))
            {
                return;
            }

            // 确保具有足够的连接信息并指定查询
            if (ConnString == "")
            {
                return;
            }

            // 获取数据
            FetchPageData();

            // 将数据绑定到合作者控件
            BaseDataList baseDataListControl = null;
            ListControl  listControl         = null;
            Repeater     repeaterControl     = null;

            if (CustomParameters)
            {
                if (this._pagedDataSource == null)
                {
                    this._pagedDataSource = new PagedDataSource();
                }
                this._pagedDataSource.PageSize = PageSize;
                TotalPage = this._pagedDataSource.PageCount;
                _pagedDataSource.CurrentPageIndex = CurPage;
                _pagedDataSource.VirtualCount     = RecordCount;
                _pagedDataSource.DataSource       = _dataSource.DefaultView;

                if (_controlToPaginate is BaseDataList)
                {
                    baseDataListControl            = (BaseDataList)_controlToPaginate;
                    baseDataListControl.DataSource = _pagedDataSource;
                    baseDataListControl.DataBind();
                    return;
                }
                if (_controlToPaginate is ListControl)
                {
                    listControl = (ListControl)_controlToPaginate;
                    listControl.Items.Clear();
                    listControl.DataSource = _pagedDataSource;
                    listControl.DataBind();
                    return;
                }
                if (_controlToPaginate is Repeater)
                {
                    repeaterControl            = (Repeater)_controlToPaginate;
                    repeaterControl.DataSource = _pagedDataSource;
                    repeaterControl.DataBind();
                    return;
                }
            }
            else
            {
                if (_controlToPaginate is BaseDataList)
                {
                    baseDataListControl            = (BaseDataList)_controlToPaginate;
                    baseDataListControl.DataSource = _dataSource.DefaultView;
                    baseDataListControl.DataBind();
                    return;
                }
                if (_controlToPaginate is ListControl)
                {
                    listControl = (ListControl)_controlToPaginate;
                    listControl.Items.Clear();
                    listControl.DataSource = _dataSource.DefaultView;
                    listControl.DataBind();
                    return;
                }
                if (_controlToPaginate is Repeater)
                {
                    repeaterControl            = (Repeater)_controlToPaginate;
                    repeaterControl.DataSource = _dataSource.DefaultView;
                    repeaterControl.DataBind();
                    return;
                }
            }
        }
Exemplo n.º 25
0
 public static void DataShow(this BaseDataList bdl, object datasource)
 {
     bdl.DataSource = datasource;
     bdl.DataBind();
 }
Exemplo n.º 26
0
 /// <summary>
 /// Bind data to DataList Control
 /// </summary>
 /// <param name="dataControl"></param>
 /// <param name="dataSource"></param>
 protected void BindDataControl(BaseDataList dataControl, object dataSource)
 {
     Container.BindDataControl(dataControl, dataSource);
 }
        protected override void SaveComponent()
        {
            BaseDataList baseControl = base.GetBaseControl();

            try
            {
                string s = this.cellPaddingEdit.Text.Trim();
                if (s.Length != 0)
                {
                    baseControl.CellPadding = int.Parse(s, CultureInfo.CurrentCulture);
                }
                else
                {
                    baseControl.CellPadding = -1;
                }
            }
            catch
            {
                if (baseControl.CellPadding != -1)
                {
                    this.cellPaddingEdit.Text = baseControl.CellPadding.ToString(NumberFormatInfo.CurrentInfo);
                }
                else
                {
                    this.cellPaddingEdit.Clear();
                }
            }
            try
            {
                string str2 = this.cellSpacingEdit.Text.Trim();
                if (str2.Length != 0)
                {
                    baseControl.CellSpacing = int.Parse(str2, CultureInfo.CurrentCulture);
                }
                else
                {
                    baseControl.CellSpacing = -1;
                }
            }
            catch
            {
                if (baseControl.CellSpacing != -1)
                {
                    this.cellSpacingEdit.Text = baseControl.CellSpacing.ToString(NumberFormatInfo.CurrentInfo);
                }
                else
                {
                    this.cellSpacingEdit.Clear();
                }
            }
            switch (this.gridLinesCombo.SelectedIndex)
            {
            case 0:
                baseControl.GridLines = GridLines.Horizontal;
                break;

            case 1:
                baseControl.GridLines = GridLines.Vertical;
                break;

            case 2:
                baseControl.GridLines = GridLines.Both;
                break;

            case 3:
                baseControl.GridLines = GridLines.None;
                break;
            }
            try
            {
                string color = this.borderColorCombo.Color;
                baseControl.BorderColor = ColorTranslator.FromHtml(color);
            }
            catch
            {
                this.borderColorCombo.Color = ColorTranslator.ToHtml(baseControl.BorderColor);
            }
            try
            {
                string str4  = this.borderWidthUnit.Value;
                Unit   empty = Unit.Empty;
                if (str4 != null)
                {
                    empty = Unit.Parse(str4, CultureInfo.CurrentCulture);
                }
                baseControl.BorderWidth = empty;
            }
            catch
            {
                this.borderWidthUnit.Value = baseControl.BorderWidth.ToString(CultureInfo.CurrentCulture);
            }
        }
Exemplo n.º 28
0
 /// <summary>
 /// 数据列表绑定
 /// </summary>
 /// <param name="dli">列表对象</param>
 public void Bind(BaseDataList dli)
 {
     dli.DataSource = this.EnumList;
     dli.DataBind();
 }
Exemplo n.º 29
0
        /// <include file='doc\BordersPage.uex' path='docs/doc[@for="BordersPage.SaveComponent"]/*' />
        /// <devdoc>
        ///   Saves the component loaded into the page.
        /// </devdoc>
        protected override void SaveComponent()
        {
            BaseDataList bdl = (BaseDataList)GetBaseControl();

            try {
                string cellPadding = cellPaddingEdit.Text.Trim();
                if (cellPadding.Length != 0)
                {
                    bdl.CellPadding = Int32.Parse(cellPadding, CultureInfo.InvariantCulture);
                }
                else
                {
                    bdl.CellPadding = -1;
                }
            } catch (Exception) {
                if (bdl.CellPadding != -1)
                {
                    cellPaddingEdit.Text = (bdl.CellPadding).ToString();
                }
                else
                {
                    cellPaddingEdit.Clear();
                }
            }

            try {
                string cellSpacing = cellSpacingEdit.Text.Trim();
                if (cellSpacing.Length != 0)
                {
                    bdl.CellSpacing = Int32.Parse(cellSpacing, CultureInfo.InvariantCulture);
                }
                else
                {
                    bdl.CellSpacing = -1;
                }
            } catch (Exception) {
                if (bdl.CellSpacing != -1)
                {
                    cellSpacingEdit.Text = (bdl.CellSpacing).ToString();
                }
                else
                {
                    cellSpacingEdit.Clear();
                }
            }

            switch (gridLinesCombo.SelectedIndex)
            {
            case IDX_GRID_HORIZONTAL:
                bdl.GridLines = GridLines.Horizontal;
                break;

            case IDX_GRID_VERTICAL:
                bdl.GridLines = GridLines.Vertical;
                break;

            case IDX_GRID_BOTH:
                bdl.GridLines = GridLines.Both;
                break;

            case IDX_GRID_NEITHER:
                bdl.GridLines = GridLines.None;
                break;
            }

            try {
                string colorValue = borderColorCombo.Color;
                bdl.BorderColor = ColorTranslator.FromHtml(colorValue);
            } catch (Exception) {
                borderColorCombo.Color = ColorTranslator.ToHtml(bdl.BorderColor);
            }

            try {
                string borderWidth = borderWidthUnit.Value;
                Unit   unitValue   = Unit.Empty;
                if (borderWidth != null)
                {
                    unitValue = Unit.Parse(borderWidth);
                }
                bdl.BorderWidth = unitValue;
            } catch (Exception) {
                borderWidthUnit.Value = bdl.BorderWidth.ToString();
            }
        }
Exemplo n.º 30
0
 public void IsBindableType_Null()
 {
     BaseDataList.IsBindableType(null);
 }