当前位置: 首页>>代码示例>>C#>>正文


C# BoundColumn.SetOwner方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.BoundColumn.SetOwner方法的典型用法代码示例。如果您正苦于以下问题:C# BoundColumn.SetOwner方法的具体用法?C# BoundColumn.SetOwner怎么用?C# BoundColumn.SetOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.BoundColumn的用法示例。


在下文中一共展示了BoundColumn.SetOwner方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAutoGeneratedColumns

        /// <devdoc>
        /// </devdoc>
        private ArrayList CreateAutoGeneratedColumns(PagedDataSource dataSource) {
            if (dataSource == null) {
                // note that we're not throwing an exception in this case, and the calling
                // code should be able to handle a null arraylist being returned
                return null;
            }

            ArrayList generatedColumns = new ArrayList();
            PropertyDescriptorCollection propDescs = null;
            bool throwException = true;

            // try ITypedList first
            // A PagedDataSource implements this, but returns null, if the underlying data source
            // does not implement it.
            propDescs = ((ITypedList)dataSource).GetItemProperties(new PropertyDescriptor[0]);

            if (propDescs == null) {
                Type sampleItemType = null;
                object sampleItem = null;

                IEnumerable realDataSource = dataSource.DataSource;
                Debug.Assert(realDataSource != null, "Must have a real data source when calling CreateAutoGeneratedColumns");

                Type dataSourceType = realDataSource.GetType();

                // try for a typed Item property, which should be present on strongly typed collections
                PropertyInfo itemProp = dataSourceType.GetProperty("Item", BindingFlags.Public | BindingFlags.Instance, null, null, new Type[] { typeof(int) }, null);
                if (itemProp != null) {
                    sampleItemType = itemProp.PropertyType;
                }

                if ((sampleItemType == null) || (sampleItemType == typeof(object))) {
                    // last resort... try to get ahold of the first item by beginning the
                    // enumeration

                    IEnumerator e = dataSource.GetEnumerator();

                    if (e.MoveNext()) {
                        sampleItem = e.Current;
                    }
                    else {
                        // we don't want to throw an exception if we're bound to an IEnumerable
                        // data source with no records... we'll simply bail and not show any data
                        throwException = false;
                    }
                    if (sampleItem != null) {
                        sampleItemType = sampleItem.GetType();
                    }

                    // We must store the enumerator regardless of whether we got back an item from it
                    // because we cannot start the enumeration again, in the case of a DataReader.
                    // Code in CreateControlHierarchy must deal appropriately for the case where
                    // there is a stored enumerator, but a null object as the first item.
                    StoreEnumerator(e, sampleItem);
                }

                if ((sampleItem != null) && (sampleItem is ICustomTypeDescriptor)) {
                    // Get the custom properties of the object
                    propDescs = TypeDescriptor.GetProperties(sampleItem);
                }
                else if (sampleItemType != null) {
                    // directly bindable types: strings, ints etc. get treated special, since we
                    // don't care about their properties, but rather we care about them directly
                    if (BaseDataList.IsBindableType(sampleItemType)) {
                        BoundColumn column = new BoundColumn();

                        ((IStateManager)column).TrackViewState();
                        column.HeaderText = "Item";
                        column.DataField = BoundColumn.thisExpr;
                        column.SortExpression = "Item";

                        column.SetOwner(this);
                        generatedColumns.Add(column);
                    }
                    else {
                        // complex type... we get its properties
                        propDescs = TypeDescriptor.GetProperties(sampleItemType);
                    }
                }
            }

            if ((propDescs != null) && (propDescs.Count != 0)) {
                foreach (PropertyDescriptor pd in propDescs) {
                    Type propType = pd.PropertyType;

                    if (BaseDataList.IsBindableType(propType)) {
                        BoundColumn column = new BoundColumn();

                        ((IStateManager)column).TrackViewState();
                        column.HeaderText = pd.Name;
                        column.DataField = pd.Name;
                        column.SortExpression = pd.Name;
                        column.ReadOnly = pd.IsReadOnly;

                        column.SetOwner(this);
                        generatedColumns.Add(column);
                    }
                }
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:DataGrid.cs

示例2: LoadViewState

        /// <internalonly/>
        /// <devdoc>
        /// <para>Loads a saved state of the <see cref='System.Web.UI.WebControls.DataGrid'/>.</para>
        /// </devdoc>
        protected override void LoadViewState(object savedState) {
            if (savedState != null) {
                object[] myState = (object[])savedState;

                if (myState[0] != null)
                    base.LoadViewState(myState[0]);
                if (myState[1] != null)
                    ((IStateManager)Columns).LoadViewState(myState[1]);
                if (myState[2] != null)
                    ((IStateManager)PagerStyle).LoadViewState(myState[2]);
                if (myState[3] != null)
                    ((IStateManager)HeaderStyle).LoadViewState(myState[3]);
                if (myState[4] != null)
                    ((IStateManager)FooterStyle).LoadViewState(myState[4]);
                if (myState[5] != null)
                    ((IStateManager)ItemStyle).LoadViewState(myState[5]);
                if (myState[6] != null)
                    ((IStateManager)AlternatingItemStyle).LoadViewState(myState[6]);
                if (myState[7] != null)
                    ((IStateManager)SelectedItemStyle).LoadViewState(myState[7]);
                if (myState[8] != null)
                    ((IStateManager)EditItemStyle).LoadViewState(myState[8]);
                if (myState[9] != null)
                    ((IStateManager)ControlStyle).LoadViewState(myState[9]);
                if (myState[10] != null) {
                    object[] autoGenColumnState = (object[])myState[10];
                    int columnCount = autoGenColumnState.Length;

                    if (columnCount != 0)
                        autoGenColumnsArray = new ArrayList();
                    else
                        autoGenColumnsArray = null;

                    for (int i = 0; i < columnCount; i++) {
                        BoundColumn column = new BoundColumn();

                        ((IStateManager)column).TrackViewState();
                        ((IStateManager)column).LoadViewState(autoGenColumnState[i]);

                        column.SetOwner(this);
                        autoGenColumnsArray.Add(column);
                    }
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:49,代码来源:DataGrid.cs

示例3: LoadViewState

		protected override void LoadViewState(object savedState)
		{
			if (savedState == null)
				return;

			object [] states = (object []) savedState;
			base.LoadViewState (states[0]);
			if(columns != null)
				((IStateManager)columns).LoadViewState(states[1]);
			if(pagerStyle != null)
				pagerStyle.LoadViewState(states[2]);
			if(headerStyle != null)
				headerStyle.LoadViewState(states[3]);
			if(footerStyle != null)
				footerStyle.LoadViewState(states[4]);
			if(itemStyle != null)
				itemStyle.LoadViewState(states[5]);
			if(alternatingItemStyle != null)
				alternatingItemStyle.LoadViewState(states[6]);
			if(selectedItemStyle != null)
				selectedItemStyle.LoadViewState(states[7]);
			if(editItemStyle != null)
				editItemStyle.LoadViewState(states[8]);

			if (states [9] != null) {
				object[] array = ((object[]) states [9]);
				if (array.Length != 0)
					this.autoGenColsArrayList = new ArrayList ();
				else
					this.autoGenColsArrayList = null; 

				for (int i = 0; i < array.Length; i++) {
					BoundColumn column1 = new BoundColumn ();
					((IStateManager)column1).TrackViewState ();
					((IStateManager)column1).LoadViewState (array [i]);
					column1.SetOwner (this);
					this.autoGenColsArrayList.Add (column1);
				} 
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:40,代码来源:DataGrid.cs

示例4: AutoCreateColumns

		/// <summary>
		/// Generates the columns when AutoGenerateColumns is true.
		/// This method is called by CreateColumnSet when dataSource
		/// is to be used and columns need to be generated automatically.
		/// </summary>
		private ArrayList AutoCreateColumns (PagedDataSource source)
		{
			if (source == null)
				return null;

			ArrayList retVal = null;
			PropertyDescriptorCollection props = source.GetItemProperties (new PropertyDescriptor [0]);
			bool empty_enumerator = false;
			Type prop_type;
			BoundColumn col;

			if (props == null) {
				object fitem = null;
				prop_type   = null;
				PropertyInfo prop_item =  source.DataSource.GetType ().GetProperty ("Item",
					  BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public,
					  null, null, new Type[] { typeof(int) }, null);
				
				if (prop_item != null)
					prop_type = prop_item.PropertyType;

				if (prop_type == null || prop_type == typeof (object)) {
					IEnumerator en = source.GetEnumerator();
					if (en.MoveNext ()) {
						fitem = en.Current;
						if (fitem != null)
							prop_type = fitem.GetType ();
					} else {
						empty_enumerator = true;
					}

					StoreEnumerator (en, fitem);
				}
				
				if (fitem is ICustomTypeDescriptor) {
					props = TypeDescriptor.GetProperties (fitem);
				} else if (prop_type != null) {
					if (IsBindableType  (prop_type)) {
						col = new BoundColumn ();
						((IStateManager) col).TrackViewState ();
						col.HeaderText = "Item";
						col.SortExpression = "Item";
						col.DataField  = BoundColumn.thisExpr;
						col.SetOwner (this);
						if (retVal == null)
							retVal = new ArrayList ();
						retVal.Add (col);
					} else {
						props = TypeDescriptor.GetProperties (prop_type);
					}
				}
			}

			if (props != null && props.Count > 0) {
				try {
					foreach (PropertyDescriptor current in props) {
						if (!IsBindableType (current.PropertyType))
							continue;

						col = new BoundColumn ();
						((IStateManager) col).TrackViewState ();
						string name = current.Name;
						col.HeaderText = name;
						col.SortExpression = name;
						col.DataField = name;
						col.ReadOnly = current.IsReadOnly;
						col.SetOwner (this);
						if (retVal == null)
							retVal = new ArrayList ();
						retVal.Add (col);
					}
				} finally {
					if (props is IDisposable)
						((IDisposable) props).Dispose ();
				}
			}

			if (retVal != null && retVal.Count > 0)
				return retVal;

			if (empty_enumerator)
				return null;

			throw new HttpException (HttpRuntime.FormatResourceString ("DataGrid_NoAutoGenColumns", ID));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:90,代码来源:DataGrid.cs

示例5: LoadViewState

 protected override void LoadViewState(object savedState)
 {
     if (savedState != null)
     {
         object[] objArray = (object[]) savedState;
         if (objArray[0] != null)
         {
             base.LoadViewState(objArray[0]);
         }
         if (objArray[1] != null)
         {
             ((IStateManager) this.Columns).LoadViewState(objArray[1]);
         }
         if (objArray[2] != null)
         {
             ((IStateManager) this.PagerStyle).LoadViewState(objArray[2]);
         }
         if (objArray[3] != null)
         {
             ((IStateManager) this.HeaderStyle).LoadViewState(objArray[3]);
         }
         if (objArray[4] != null)
         {
             ((IStateManager) this.FooterStyle).LoadViewState(objArray[4]);
         }
         if (objArray[5] != null)
         {
             ((IStateManager) this.ItemStyle).LoadViewState(objArray[5]);
         }
         if (objArray[6] != null)
         {
             ((IStateManager) this.AlternatingItemStyle).LoadViewState(objArray[6]);
         }
         if (objArray[7] != null)
         {
             ((IStateManager) this.SelectedItemStyle).LoadViewState(objArray[7]);
         }
         if (objArray[8] != null)
         {
             ((IStateManager) this.EditItemStyle).LoadViewState(objArray[8]);
         }
         if (objArray[9] != null)
         {
             ((IStateManager) base.ControlStyle).LoadViewState(objArray[9]);
         }
         if (objArray[10] != null)
         {
             object[] objArray2 = (object[]) objArray[10];
             int length = objArray2.Length;
             if (length != 0)
             {
                 this.autoGenColumnsArray = new ArrayList();
             }
             else
             {
                 this.autoGenColumnsArray = null;
             }
             for (int i = 0; i < length; i++)
             {
                 BoundColumn column = new BoundColumn();
                 ((IStateManager) column).TrackViewState();
                 ((IStateManager) column).LoadViewState(objArray2[i]);
                 column.SetOwner(this);
                 this.autoGenColumnsArray.Add(column);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:68,代码来源:DataGrid.cs

示例6: CreateAutoGeneratedColumns

 private ArrayList CreateAutoGeneratedColumns(PagedDataSource dataSource)
 {
     if (dataSource == null)
     {
         return null;
     }
     ArrayList list = new ArrayList();
     PropertyDescriptorCollection itemProperties = null;
     bool flag = true;
     itemProperties = dataSource.GetItemProperties(new PropertyDescriptor[0]);
     if (itemProperties == null)
     {
         Type propertyType = null;
         object firstDataItem = null;
         PropertyInfo info = dataSource.DataSource.GetType().GetProperty("Item", BindingFlags.Public | BindingFlags.Instance, null, null, new Type[] { typeof(int) }, null);
         if (info != null)
         {
             propertyType = info.PropertyType;
         }
         if ((propertyType == null) || (propertyType == typeof(object)))
         {
             IEnumerator enumerator = dataSource.GetEnumerator();
             if (enumerator.MoveNext())
             {
                 firstDataItem = enumerator.Current;
             }
             else
             {
                 flag = false;
             }
             if (firstDataItem != null)
             {
                 propertyType = firstDataItem.GetType();
             }
             this.StoreEnumerator(enumerator, firstDataItem);
         }
         if ((firstDataItem != null) && (firstDataItem is ICustomTypeDescriptor))
         {
             itemProperties = TypeDescriptor.GetProperties(firstDataItem);
         }
         else if (propertyType != null)
         {
             if (BaseDataList.IsBindableType(propertyType))
             {
                 BoundColumn column = new BoundColumn();
                 ((IStateManager) column).TrackViewState();
                 column.HeaderText = "Item";
                 column.DataField = BoundColumn.thisExpr;
                 column.SortExpression = "Item";
                 column.SetOwner(this);
                 list.Add(column);
             }
             else
             {
                 itemProperties = TypeDescriptor.GetProperties(propertyType);
             }
         }
     }
     if ((itemProperties != null) && (itemProperties.Count != 0))
     {
         foreach (PropertyDescriptor descriptor in itemProperties)
         {
             if (BaseDataList.IsBindableType(descriptor.PropertyType))
             {
                 BoundColumn column2 = new BoundColumn();
                 ((IStateManager) column2).TrackViewState();
                 column2.HeaderText = descriptor.Name;
                 column2.DataField = descriptor.Name;
                 column2.SortExpression = descriptor.Name;
                 column2.ReadOnly = descriptor.IsReadOnly;
                 column2.SetOwner(this);
                 list.Add(column2);
             }
         }
     }
     if ((list.Count == 0) && flag)
     {
         throw new HttpException(System.Web.SR.GetString("DataGrid_NoAutoGenColumns", new object[] { this.ID }));
     }
     return list;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:81,代码来源:DataGrid.cs


注:本文中的System.Web.UI.WebControls.BoundColumn.SetOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。