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


C# PagedDataSource.GetEnumerator方法代码示例

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


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

示例1: CreateControlHierarchy

        /// <internalonly/>
        /// <devdoc>
        ///    <para>Creates the control hierarchy that is used to render the DataGrid.
        ///       This is called whenever a control hierarchy is needed and the
        ///       ChildControlsCreated property is false.
        ///       The implementation assumes that all the children in the controls
        ///       collection have already been cleared.</para>
        /// </devdoc>
        protected override void CreateControlHierarchy(bool useDataSource) {
            pagedDataSource = CreatePagedDataSource();

            IEnumerator dataSource = null;
            int count = -1;
            int totalCount = -1;
            ArrayList keysArray = DataKeysArray;
            ArrayList columnsArray = null;

            if (itemsArray != null) {
                itemsArray.Clear();
            }
            else {
                itemsArray = new ArrayList();
            }
            itemsCollection = null;

            if (useDataSource == false) {
                // ViewState must have a non-null value for ItemCount because we check for
                // this in CreateChildControls
                count = (int)ViewState[BaseDataList.ItemCountViewStateKey];
                totalCount = (int)ViewState[DataSourceItemCountViewStateKey];

                if (count != -1) {
                    if (pagedDataSource.IsCustomPagingEnabled) {
                        pagedDataSource.DataSource = new DummyDataSource(count);
                    }
                    else {
                        pagedDataSource.DataSource = new DummyDataSource(totalCount);
                    }
                    dataSource = pagedDataSource.GetEnumerator();
                    columnsArray = CreateColumnSet(null, false);

                    itemsArray.Capacity = count;
                }
            }
            else {
                keysArray.Clear();

                IEnumerable realDataSource = GetData();

                if (realDataSource != null) {
                    ICollection collection = realDataSource as ICollection;

                    if ((collection == null) &&
                        pagedDataSource.IsPagingEnabled && !pagedDataSource.IsCustomPagingEnabled) {
                        throw new HttpException(SR.GetString(SR.DataGrid_Missing_VirtualItemCount, ID));
                    }

                    pagedDataSource.DataSource = realDataSource;
                    if (pagedDataSource.IsPagingEnabled) {
                        if ((pagedDataSource.CurrentPageIndex < 0) || (pagedDataSource.CurrentPageIndex >= pagedDataSource.PageCount)) {
                            throw new HttpException(SR.GetString(SR.Invalid_CurrentPageIndex));
                        }
                    }
                    columnsArray = CreateColumnSet(pagedDataSource, useDataSource);

                    if (storedDataValid) {
                        dataSource = storedData;
                    }
                    else {
                        dataSource = pagedDataSource.GetEnumerator();
                    }

                    if (collection != null) {
                        int initialCapacity = pagedDataSource.Count;
                        keysArray.Capacity = initialCapacity;
                        itemsArray.Capacity = initialCapacity;
                    }
                }
            }

            int columnCount = 0;
            if (columnsArray != null)
                columnCount = columnsArray.Count;

            if (columnCount > 0) {
                DataGridColumn[] displayColumns = new DataGridColumn[columnCount];
                columnsArray.CopyTo(displayColumns, 0);

                Table table = new ChildTable(String.IsNullOrEmpty(ID) ? null : ClientID);
                Controls.Add(table);
                
                for (int c = 0; c < displayColumns.Length; c++) {
                    displayColumns[c].Initialize();
                }

                TableRowCollection rows = table.Rows;
                DataGridItem item;
                ListItemType itemType;
                int index = 0;
                int dataSetIndex = 0;
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:DataGrid.cs

示例2: CreateControlHierarchy

		protected override void CreateControlHierarchy(bool useDataSource)
		{
			IEnumerator pageSourceEnumerator;
			int         itemCount;
			ArrayList   dataKeys;
			ArrayList   columns;
			IEnumerable resolvedDS;
			ICollection collResolvedDS;
			int         pageDSCount;
			int         colCount;
			DataGridColumn[] cols;
			Table       deployTable;
			TableRowCollection deployRows;
			ListItemType deployType;
			int         indexCounter;
			string      dkField;
			bool        dsUse;
			bool        pgEnabled;
			int         editIndex;
			int         selIndex;

			pagedDataSource = CreatePagedDataSource();
			pageSourceEnumerator  = null;
			itemCount       = -1;
			dataKeys        = DataKeysArray;
			columns         = null;
			if(itemsArrayList != null)
			{
				itemsArrayList.Clear();
			} else
			{
				itemsArrayList = new ArrayList();
			}
			if(!useDataSource)
			{
				itemCount    = (int) ViewState["_!ItemCount"];
				pageDSCount  = (int) ViewState["_!DataSource_ItemCount"];
				if(itemCount != -1)
				{
					if(pagedDataSource.IsCustomPagingEnabled)
					{
						pagedDataSource.DataSource = new DataSourceInternal(itemCount);
					} else
					{
						pagedDataSource.DataSource = new DataSourceInternal(pageDSCount);
					}
					pageSourceEnumerator = pagedDataSource.GetEnumerator();
					columns              = CreateColumnSet(null, false);
					itemsArrayList.Capacity = itemCount;
				}
			} else
			{
				dataKeys.Clear();
				resolvedDS = GetResolvedDataSource ();
				if(resolvedDS != null)
				{
					collResolvedDS = resolvedDS as ICollection;
					if(pagedDataSource.IsPagingEnabled && !pagedDataSource.IsCustomPagingEnabled
					   && collResolvedDS == null)
					{
						throw new HttpException(HttpRuntime.FormatResourceString("DataGrid_Missing_VirtualItemCount", ID));
					}
					pagedDataSource.DataSource = resolvedDS;
					if(pagedDataSource.IsPagingEnabled && (pagedDataSource.CurrentPageIndex < 0 ||
							pagedDataSource.PageCount < pagedDataSource.CurrentPageIndex))
					{
						throw new HttpException(HttpRuntime.FormatResourceString("DataGrid_Invalid_Current_PageIndex", ID));
					}
					columns = CreateColumnSet(pagedDataSource, useDataSource);

					if(storedDataValid)
					{
						pageSourceEnumerator = storedData;
					} else
					{
						pageSourceEnumerator = pagedDataSource.GetEnumerator();
					}
					if(collResolvedDS != null)
					{
						pageDSCount         = pagedDataSource.Count;
						dataKeys.Capacity   = pageDSCount;
						itemsArrayList.Capacity = pageDSCount;
					}
				}
			}

			colCount = 0;
			if(columns != null)
				colCount = columns.Count;
			int currentSourceIndex;
			if(colCount > 0)
			{
				cols = (DataGridColumn []) columns.ToArray (typeof (DataGridColumn));
				foreach(DataGridColumn current in cols)
				{
					current.Initialize();
				}
				deployTable = new DataGridTableInternal();
				Controls.Add(deployTable);
				deployRows = deployTable.Rows;
//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:DataGrid.cs

示例3: 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

示例4: 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

示例5: CreateChildControls

		protected override int CreateChildControls (IEnumerable data, bool dataBinding)
		{
			PagedDataSource dataSource = new PagedDataSource ();
			dataSource.DataSource = CurrentMode != FormViewMode.Insert ? data : null;
			dataSource.AllowPaging = AllowPaging;
			dataSource.PageSize = 1;
			dataSource.CurrentPageIndex = PageIndex;

			if (dataBinding && CurrentMode != FormViewMode.Insert) {
				DataSourceView view = GetData ();
				if (view != null && view.CanPage) {
					dataSource.AllowServerPaging = true;
					if (SelectArguments.RetrieveTotalRowCount)
						dataSource.VirtualCount = SelectArguments.TotalRowCount;
				}
			}

			PagerSettings pagerSettings = PagerSettings;
			bool showPager = AllowPaging && pagerSettings.Visible && (dataSource.PageCount > 1);
			
			Controls.Clear ();
			table = CreateTable ();
			Controls.Add (table);
			headerRow = null;
			footerRow = null;
			topPagerRow = null;
			bottomPagerRow = null;

			// Gets the current data item

			if (AllowPaging) {
				PageCount = dataSource.DataSourceCount;
				if (PageIndex >= PageCount && PageCount > 0)
					pageIndex = dataSource.CurrentPageIndex = PageCount - 1;
				
				if (dataSource.DataSource != null) {
					IEnumerator e = dataSource.GetEnumerator ();
					if (e.MoveNext ())
						dataItem = e.Current;
				}
			} else {
				int page = 0;
				object lastItem = null;
				if (dataSource.DataSource != null) {
					IEnumerator e = dataSource.GetEnumerator ();
					for (; e.MoveNext (); page++) {
						lastItem = e.Current;
						if (page == PageIndex)
							dataItem = e.Current;
					}
				}
				PageCount = page;
				if (PageIndex >= PageCount && PageCount > 0) {
					pageIndex = PageCount - 1;
					dataItem = lastItem;
				}
			}

			// Main table creation
			bool emptyRow = PageCount == 0 && CurrentMode != FormViewMode.Insert;

			if (!emptyRow) {
				headerRow = CreateRow (-1, DataControlRowType.Header, DataControlRowState.Normal);
				InitializeRow (headerRow);
				table.Rows.Add (headerRow);
			}

			if (showPager && pagerSettings.Position == PagerPosition.Top || pagerSettings.Position == PagerPosition.TopAndBottom) {
				topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
				InitializePager (topPagerRow, dataSource);
				table.Rows.Add (topPagerRow);
			}

			if (PageCount > 0) {
				DataControlRowState rstate = GetRowState ();
				itemRow = CreateRow (0, DataControlRowType.DataRow, rstate);
				InitializeRow (itemRow);
				table.Rows.Add (itemRow);
			} else {
				switch (CurrentMode) {
					case FormViewMode.Edit:
						itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Edit);
						break;
					case FormViewMode.Insert:
						itemRow = CreateRow (-1, DataControlRowType.DataRow, DataControlRowState.Insert);
						break;
					default:
						itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
						break;
				}
				InitializeRow (itemRow);
				table.Rows.Add (itemRow);
			}

			if (!emptyRow) {
				footerRow = CreateRow (-1, DataControlRowType.Footer, DataControlRowState.Normal);
				InitializeRow (footerRow);
				table.Rows.Add (footerRow);
			}
			
//.........这里部分代码省略.........
开发者ID:Profit0004,项目名称:mono,代码行数:101,代码来源:FormView.cs

示例6: CreateAutoGeneratedColumns

 private ICollection CreateAutoGeneratedColumns(PagedDataSource dataSource)
 {
     if (dataSource == null)
     {
         return null;
     }
     ArrayList list = new ArrayList();
     this._autoGenFieldProps = new ArrayList();
     PropertyDescriptorCollection itemProperties = null;
     bool flag = true;
     itemProperties = dataSource.GetItemProperties(new PropertyDescriptor[0]);
     if (itemProperties == null)
     {
         Type propertyType = null;
         object firstDataRow = 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())
             {
                 firstDataRow = enumerator.Current;
             }
             else
             {
                 flag = false;
             }
             if (firstDataRow != null)
             {
                 propertyType = firstDataRow.GetType();
             }
             this.StoreEnumerator(enumerator, firstDataRow);
         }
         if ((firstDataRow != null) && (firstDataRow is ICustomTypeDescriptor))
         {
             itemProperties = TypeDescriptor.GetProperties(firstDataRow);
         }
         else if (propertyType != null)
         {
             if (this.IsBindableType(propertyType))
             {
                 AutoGeneratedFieldProperties fieldProperties = new AutoGeneratedFieldProperties();
                 ((IStateManager) fieldProperties).TrackViewState();
                 fieldProperties.Type = propertyType;
                 fieldProperties.Name = "Item";
                 fieldProperties.DataField = BoundField.ThisExpression;
                 AutoGeneratedField field = this.CreateAutoGeneratedColumn(fieldProperties);
                 if (field != null)
                 {
                     list.Add(field);
                     this._autoGenFieldProps.Add(fieldProperties);
                 }
             }
             else
             {
                 itemProperties = TypeDescriptor.GetProperties(propertyType);
             }
         }
     }
     else if (itemProperties.Count == 0)
     {
         flag = false;
     }
     if ((itemProperties != null) && (itemProperties.Count != 0))
     {
         string[] dataKeyNames = this.DataKeyNames;
         int length = dataKeyNames.Length;
         string[] strArray2 = new string[length];
         for (int i = 0; i < length; i++)
         {
             strArray2[i] = dataKeyNames[i].ToLowerInvariant();
         }
         foreach (PropertyDescriptor descriptor in itemProperties)
         {
             Type type = descriptor.PropertyType;
             if (this.IsBindableType(type))
             {
                 string name = descriptor.Name;
                 bool flag2 = strArray2.Contains(name.ToLowerInvariant());
                 AutoGeneratedFieldProperties properties2 = new AutoGeneratedFieldProperties();
                 ((IStateManager) properties2).TrackViewState();
                 properties2.Name = name;
                 properties2.IsReadOnly = flag2;
                 properties2.Type = type;
                 properties2.DataField = name;
                 AutoGeneratedField field2 = this.CreateAutoGeneratedColumn(properties2);
                 if (field2 != null)
                 {
                     list.Add(field2);
                     this._autoGenFieldProps.Add(properties2);
                 }
             }
         }
     }
     if ((list.Count == 0) && flag)
     {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:GridView.cs

示例7: AddColumnsFromSource

		void AddColumnsFromSource (PagedDataSource data_source)
		{
			PropertyDescriptorCollection props = null;
			Type ptype = null;
			bool no_items = false;

			// Use plain reflection for the Item property.
			// If we use TypeDescriptor, props will hold
			// all of the Type properties, which will be listed as columns
			Type ds_type = data_source.GetType ();
			PropertyInfo pinfo = ds_type.GetProperty ("Item", item_args);
			if (pinfo == null) {
				IEnumerator items = (data_source.DataSource != null) ? data_source.GetEnumerator () : null;
				if (items != null && items.MoveNext ()) {
					object data = items.Current;
					if ((data is ICustomTypeDescriptor) || (!IsBindableType(data.GetType())))
						props = TypeDescriptor.GetProperties (data);
					else if (data != null)
						ptype = data.GetType ();
					data_enumerator = items;
				} else {
					no_items = true;
				}
			} else {
				ptype = pinfo.PropertyType;
			}

			if (ptype != null) {
				// Found the "Item" property
				AddPropertyToColumns ();
			} else if (props != null) {
				foreach (PropertyDescriptor pd in props)
					AddPropertyToColumns (pd, false);
			} else if (!no_items) {
				// This is not thrown for an empty ArrayList.
				string msg = String.Format ("DataGrid '{0}' cannot autogenerate " +
							"columns from the given datasource. {1}", ID, ptype);
				throw new HttpException (msg);
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:40,代码来源:DataGrid.cs

示例8: Paging4

		public void Paging4 ()
		{
			PagedDataSource paged = new PagedDataSource ();
			paged.AllowPaging = true;
			paged.PageSize = 5;
			DataTable table = new DataTable ();
			FillTable (table, 100);
			paged.DataSource = new DataView (table);

			paged.CurrentPageIndex = 1;
			IEnumerator rator = paged.GetEnumerator ();
			Assert.IsTrue (rator.MoveNext (), "beginning-1");
			DataRowView drv = (DataRowView) rator.Current;
			int one = Int32.Parse ((string) drv ["one"]);
			Assert.IsTrue (one == 0 || one == 1, "one-1");
			int res =  one + 2 * Int32.Parse ((string) drv ["two"]);
			Assert.AreEqual (5, res, "five");
		}
开发者ID:nobled,项目名称:mono,代码行数:18,代码来源:PagedDataSourceTest.cs

示例9: VirtualPager2

		public void VirtualPager2 ()
		{
			PagedDataSource paged = new PagedDataSource ();
			paged.AllowPaging = true;
			paged.PageSize = 100;
			paged.VirtualCount = 50;
			paged.AllowCustomPaging = true;
			DataTable table = new DataTable ();
			FillTable (table, 100);
			paged.DataSource = new DataView (table);

			int count = 0;
			IEnumerator rator = paged.GetEnumerator ();
			while (rator.MoveNext ())
				count++;
			Assert.AreEqual (100, count, "count");
			Assert.AreEqual (true, paged.IsFirstPage, "first");
			Assert.AreEqual (true, paged.IsLastPage, "last");
		}
开发者ID:nobled,项目名称:mono,代码行数:19,代码来源:PagedDataSourceTest.cs

示例10: Paging1

		public void Paging1 ()
		{
			PagedDataSource paged = new PagedDataSource ();
			paged.AllowPaging = true;
			paged.PageSize = 5;
			DataTable table = new DataTable ();
			FillTable (table, 100);
			paged.DataSource = new DataView (table);

			Assert.IsTrue (paged.IsFirstPage, "first-1");
			Assert.IsFalse (paged.IsLastPage, "last-1");

			paged.CurrentPageIndex = 100; // no problem setting this.
			Assert.AreEqual (100, paged.CurrentPageIndex, "current-1");
			Assert.IsFalse (paged.IsFirstPage, "first-2");
			Assert.IsFalse (paged.IsLastPage, "last-2");
			IEnumerator rator = paged.GetEnumerator ();
			Assert.IsFalse (rator.MoveNext (), "beyondtheend-1");
		}
开发者ID:nobled,项目名称:mono,代码行数:19,代码来源:PagedDataSourceTest.cs

示例11: Paging3

		public void Paging3 ()
		{
			PagedDataSource paged = new PagedDataSource ();
			paged.AllowPaging = true;
			paged.PageSize = 5;
			DataTable table = new DataTable ();
			FillTable (table, 100);
			paged.DataSource = new DataView (table);

			paged.CurrentPageIndex = -7;
			Assert.AreEqual (-7, paged.CurrentPageIndex, "current");
			Assert.IsFalse (paged.IsFirstPage, "first");
			Assert.IsFalse (paged.IsLastPage, "last");
			IEnumerator rator = paged.GetEnumerator ();
			Assert.AreEqual (-7, paged.CurrentPageIndex, "current-2");
			Assert.IsTrue (rator.MoveNext (), "beyondtheend");
			DataRowView drv = (DataRowView) rator.Current; // Throws (out of range)
		}
开发者ID:nobled,项目名称:mono,代码行数:18,代码来源:PagedDataSourceTest.cs

示例12: NullSource

		public void NullSource ()
		{
			PagedDataSource ds = new PagedDataSource ();
			ds.DataSource = null;
			IEnumerator data = ds.GetEnumerator ();
		}
开发者ID:nobled,项目名称:mono,代码行数:6,代码来源:PagedDataSourceTest.cs

示例13: TestEnumerators_NoPaging

		public void TestEnumerators_NoPaging ()
		{
			PagedDataSource ds = new PagedDataSource ();
			ds.AllowPaging = false;

			//
			// Collection Enumerator
			//
			Queue q = new Queue ();
			for (int i = 0; i < 50; i++)
				q.Enqueue (i);
			ds.DataSource = q;
			EnumeratorTester_NoPaging (ds.GetEnumerator (), "collection");
			
			//
			// List Enumerator
			//
			ArrayList l = new ArrayList ();
			for (int i = 0; i < 50; i++)
				l.Add (i);
			EnumeratorTester_NoPaging (ds.GetEnumerator (), "list");
		}
开发者ID:nobled,项目名称:mono,代码行数:22,代码来源:PagedDataSourceTest.cs

示例14: TestEnumerators

		public void TestEnumerators ()
		{
			PagedDataSource ds = new PagedDataSource ();
			ds.AllowPaging = true;
			ds.PageSize = 10;
			ds.CurrentPageIndex = 2;


			//
			// Collection Enumerator
			//
			Queue q = new Queue ();
			for (int i = 0; i < 50; i++)
				q.Enqueue (i);
			ds.DataSource = q;
			EnumeratorTester (ds.GetEnumerator (), "collection");
			
			//
			// List Enumerator
			//
			ArrayList l = new ArrayList ();
			for (int i = 0; i < 50; i++)
				l.Add (i);
			EnumeratorTester (ds.GetEnumerator (), "list");
		}
开发者ID:nobled,项目名称:mono,代码行数:25,代码来源:PagedDataSourceTest.cs

示例15: 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


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