protected internal override void CreateChildControls() { this.Controls.Clear(); object obj2 = this.ViewState["_!ItemCount"]; if ((obj2 == null) && base.RequiresDataBinding) { this.EnsureDataBound(); } if ((obj2 != null) && (((int) obj2) != -1)) { DummyDataSource dataSource = new DummyDataSource((int) obj2); this.CreateChildControls(dataSource, false); base.ClearChildViewState(); } }
protected internal override void CreateChildControls() { this.Controls.Clear(); object obj2 = this.ViewState["_!ItemCount"]; if ((obj2 == null) && base.RequiresDataBinding) { this.EnsureDataBound(); } if ((obj2 != null) && (((int)obj2) != -1)) { DummyDataSource dataSource = new DummyDataSource((int)obj2); this.CreateChildControls(dataSource, false); base.ClearChildViewState(); } }
/// <summary> /// Overriden by DataBoundControl to determine if the control should /// recreate its control hierarchy based on values in view state. /// If the control hierarchy should be created, i.e. view state does /// exist, it calls CreateChildControls with a dummy (empty) data source /// which is usable for enumeration purposes only. /// </summary> protected internal override void CreateChildControls() { Controls.Clear(); object controlCount = ViewState[ItemCountViewStateKey]; if (controlCount == null && RequiresDataBinding) { EnsureDataBound(); } if (controlCount != null && ((int)controlCount) != -1) { DummyDataSource dummyDataSource = new DummyDataSource((int)controlCount); CreateChildControls(dummyDataSource, false); ClearChildViewState(); } }
/// <devdoc> /// A protected method. Creates a control /// hierarchy, with or without the data source as specified. /// </devdoc> protected virtual void CreateControlHierarchy(bool useDataSource) { IEnumerable dataSource = null; if (itemsArray != null) { itemsArray.Clear(); } else { itemsArray = new ArrayList(); } if (!useDataSource) { // ViewState must have a non-null value for ItemCount because we check for // this in CreateChildControls int count = (int)ViewState[ItemCountViewStateKey]; if (count != -1) { dataSource = new DummyDataSource(count); itemsArray.Capacity = count; } AddDataItemsIntoItemsArray(dataSource, useDataSource); } else { dataSource = GetData(); PostGetDataAction(dataSource); } }
/// <devdoc> /// A protected method. Creates a control /// hierarchy, with or without the data source as specified. /// </devdoc> protected virtual void CreateControlHierarchy(bool useDataSource) { IEnumerable dataSource = null; int count = -1; if (itemsArray != null) { itemsArray.Clear(); } else { itemsArray = new ArrayList(); } if (useDataSource == false) { // ViewState must have a non-null value for ItemCount because we check for // this in CreateChildControls count = (int)ViewState[ItemCountViewStateKey]; if (count != -1) { dataSource = new DummyDataSource(count); itemsArray.Capacity = count; } } else { dataSource = GetData(); ICollection collection = dataSource as ICollection; if (collection != null) { itemsArray.Capacity = collection.Count; } } if (dataSource != null) { RepeaterItem item; ListItemType itemType; int index = 0; bool hasSeparators = (separatorTemplate != null); count = 0; if (headerTemplate != null) { CreateItem(-1, ListItemType.Header, useDataSource, null); } foreach (object dataItem in dataSource) { // rather than creating separators after the item, we create the separator // for the previous item in all iterations of this loop. // this is so that we don't create a separator for the last item if (hasSeparators && (count > 0)) { CreateItem(index - 1, ListItemType.Separator, useDataSource, null); } itemType = (index % 2 == 0) ? ListItemType.Item : ListItemType.AlternatingItem; item = CreateItem(index, itemType, useDataSource, dataItem); itemsArray.Add(item); count++; index++; } if (footerTemplate != null) { CreateItem(-1, ListItemType.Footer, useDataSource, null); } } if (useDataSource) { // save the number of items contained in the repeater for use in round-trips ViewState[ItemCountViewStateKey] = ((dataSource != null) ? count : -1); } }
protected override void CreateControlHierarchy(bool useDataSource) { IEnumerable data = null; int dataItemCount = -1; ArrayList dataKeysArray = base.DataKeysArray; this.extractTemplateRows = this.ExtractTemplateRows; if (this.itemsArray != null) { this.itemsArray.Clear(); } else { this.itemsArray = new ArrayList(); } if (!useDataSource) { dataItemCount = (int)this.ViewState["_!ItemCount"]; if (dataItemCount != -1) { data = new DummyDataSource(dataItemCount); this.itemsArray.Capacity = dataItemCount; } } else { dataKeysArray.Clear(); data = this.GetData(); ICollection is2 = data as ICollection; if (is2 != null) { dataKeysArray.Capacity = is2.Count; this.itemsArray.Capacity = is2.Count; } } if (data != null) { ControlCollection controls = this.Controls; int itemIndex = 0; bool flag = this.separatorTemplate != null; int editItemIndex = this.EditItemIndex; int selectedIndex = this.SelectedIndex; string dataKeyField = this.DataKeyField; bool flag2 = useDataSource && (dataKeyField.Length != 0); dataItemCount = 0; if (this.headerTemplate != null) { this.CreateItem(-1, ListItemType.Header, useDataSource, null); } foreach (object obj2 in data) { if (flag2) { object propertyValue = DataBinder.GetPropertyValue(obj2, dataKeyField); dataKeysArray.Add(propertyValue); } ListItemType itemType = ListItemType.Item; if (itemIndex == editItemIndex) { itemType = ListItemType.EditItem; } else if (itemIndex == selectedIndex) { itemType = ListItemType.SelectedItem; } else if ((itemIndex % 2) != 0) { itemType = ListItemType.AlternatingItem; } DataListItem item = this.CreateItem(itemIndex, itemType, useDataSource, obj2); this.itemsArray.Add(item); if (flag) { this.CreateItem(itemIndex, ListItemType.Separator, useDataSource, null); } dataItemCount++; itemIndex++; } if (this.footerTemplate != null) { this.CreateItem(-1, ListItemType.Footer, useDataSource, null); } } if (useDataSource) { this.ViewState["_!ItemCount"] = (data != null) ? dataItemCount : -1; } }
protected virtual void CreateControlHierarchy(bool useDataSource) { IEnumerable data = null; int dataItemCount = -1; if (this.itemsArray != null) { this.itemsArray.Clear(); } else { this.itemsArray = new ArrayList(); } if (!useDataSource) { dataItemCount = (int)this.ViewState["_!ItemCount"]; if (dataItemCount != -1) { data = new DummyDataSource(dataItemCount); this.itemsArray.Capacity = dataItemCount; } } else { data = this.GetData(); ICollection is2 = data as ICollection; if (is2 != null) { this.itemsArray.Capacity = is2.Count; } } if (data != null) { int itemIndex = 0; bool flag = this.separatorTemplate != null; dataItemCount = 0; if (this.headerTemplate != null) { this.CreateItem(-1, ListItemType.Header, useDataSource, null); } foreach (object obj2 in data) { if (flag && (dataItemCount > 0)) { this.CreateItem(itemIndex - 1, ListItemType.Separator, useDataSource, null); } ListItemType itemType = ((itemIndex % 2) == 0) ? ListItemType.Item : ListItemType.AlternatingItem; RepeaterItem item = this.CreateItem(itemIndex, itemType, useDataSource, obj2); this.itemsArray.Add(item); dataItemCount++; itemIndex++; } if (this.footerTemplate != null) { this.CreateItem(-1, ListItemType.Footer, useDataSource, null); } } if (useDataSource) { this.ViewState["_!ItemCount"] = (data != null) ? dataItemCount : -1; } }
protected virtual void CreateControlHierarchy(bool useDataSource) { IEnumerable data = null; int dataItemCount = -1; if (this.itemsArray != null) { this.itemsArray.Clear(); } else { this.itemsArray = new ArrayList(); } if (!useDataSource) { dataItemCount = (int) this.ViewState["_!ItemCount"]; if (dataItemCount != -1) { data = new DummyDataSource(dataItemCount); this.itemsArray.Capacity = dataItemCount; } } else { data = this.GetData(); ICollection is2 = data as ICollection; if (is2 != null) { this.itemsArray.Capacity = is2.Count; } } if (data != null) { int itemIndex = 0; bool flag = this.separatorTemplate != null; dataItemCount = 0; if (this.headerTemplate != null) { this.CreateItem(-1, ListItemType.Header, useDataSource, null); } foreach (object obj2 in data) { if (flag && (dataItemCount > 0)) { this.CreateItem(itemIndex - 1, ListItemType.Separator, useDataSource, null); } ListItemType itemType = ((itemIndex % 2) == 0) ? ListItemType.Item : ListItemType.AlternatingItem; RepeaterItem item = this.CreateItem(itemIndex, itemType, useDataSource, obj2); this.itemsArray.Add(item); dataItemCount++; itemIndex++; } if (this.footerTemplate != null) { this.CreateItem(-1, ListItemType.Footer, useDataSource, null); } } if (useDataSource) { this.ViewState["_!ItemCount"] = (data != null) ? dataItemCount : -1; } }
/// <internalonly/> /// <devdoc> /// </devdoc> protected override void CreateControlHierarchy(bool useDataSource) { IEnumerable dataSource = null; int count = -1; ArrayList keysArray = DataKeysArray; // cache this, so we don't need to go to the statebag each time extractTemplateRows = this.ExtractTemplateRows; if (itemsArray != null) { itemsArray.Clear(); } else { itemsArray = new ArrayList(); } if (useDataSource == false) { // ViewState must have a non-null value for ItemCount because we check for // this in CreateChildControls count = (int)ViewState[BaseDataList.ItemCountViewStateKey]; if (count != -1) { dataSource = new DummyDataSource(count); itemsArray.Capacity = count; } } else { keysArray.Clear(); dataSource = GetData(); ICollection collection = dataSource as ICollection; if (collection != null) { keysArray.Capacity = collection.Count; itemsArray.Capacity = collection.Count; } } if (dataSource != null) { ControlCollection controls = Controls; DataListItem item; ListItemType itemType; int index = 0; bool hasSeparators = (separatorTemplate != null); int editItemIndex = EditItemIndex; int selectedItemIndex = SelectedIndex; string keyField = DataKeyField; bool storeKeys = (useDataSource && (keyField.Length != 0)); count = 0; if (headerTemplate != null) { CreateItem(-1, ListItemType.Header, useDataSource, null); } foreach (object dataItem in dataSource) { if (storeKeys) { object keyValue = DataBinder.GetPropertyValue(dataItem, keyField); keysArray.Add(keyValue); } itemType = ListItemType.Item; if (index == editItemIndex) { itemType = ListItemType.EditItem; } else if (index == selectedItemIndex) { itemType = ListItemType.SelectedItem; } else if (index % 2 != 0) { itemType = ListItemType.AlternatingItem; } item = CreateItem(index, itemType, useDataSource, dataItem); itemsArray.Add(item); if (hasSeparators) { CreateItem(index, ListItemType.Separator, useDataSource, null); } count++; index++; } if (footerTemplate != null) { CreateItem(-1, ListItemType.Footer, useDataSource, null); } } if (useDataSource) { // save the number of items contained in the DataList for use in round-trips ViewState[BaseDataList.ItemCountViewStateKey] = ((dataSource != null) ? count : -1); } }
/// <summary> /// Overriden by DataBoundControl to determine if the control should /// recreate its control hierarchy based on values in view state. /// If the control hierarchy should be created, i.e. view state does /// exist, it calls CreateChildControls with a dummy (empty) data source /// which is usable for enumeration purposes only. /// </summary> protected internal override void CreateChildControls() { Controls.Clear(); object controlCount = ViewState[ItemCountViewStateKey]; if (controlCount == null && RequiresDataBinding) { EnsureDataBound(); } if (controlCount != null && ((int)controlCount) != -1) { DummyDataSource dummyDataSource = new DummyDataSource((int)controlCount); CreateChildControls(dummyDataSource, false); ClearChildViewState(); } }
protected override void CreateControlHierarchy(bool useDataSource) { IEnumerable data = null; int dataItemCount = -1; ArrayList dataKeysArray = base.DataKeysArray; this.extractTemplateRows = this.ExtractTemplateRows; if (this.itemsArray != null) { this.itemsArray.Clear(); } else { this.itemsArray = new ArrayList(); } if (!useDataSource) { dataItemCount = (int) this.ViewState["_!ItemCount"]; if (dataItemCount != -1) { data = new DummyDataSource(dataItemCount); this.itemsArray.Capacity = dataItemCount; } } else { dataKeysArray.Clear(); data = this.GetData(); ICollection is2 = data as ICollection; if (is2 != null) { dataKeysArray.Capacity = is2.Count; this.itemsArray.Capacity = is2.Count; } } if (data != null) { ControlCollection controls = this.Controls; int itemIndex = 0; bool flag = this.separatorTemplate != null; int editItemIndex = this.EditItemIndex; int selectedIndex = this.SelectedIndex; string dataKeyField = this.DataKeyField; bool flag2 = useDataSource && (dataKeyField.Length != 0); dataItemCount = 0; if (this.headerTemplate != null) { this.CreateItem(-1, ListItemType.Header, useDataSource, null); } foreach (object obj2 in data) { if (flag2) { object propertyValue = DataBinder.GetPropertyValue(obj2, dataKeyField); dataKeysArray.Add(propertyValue); } ListItemType itemType = ListItemType.Item; if (itemIndex == editItemIndex) { itemType = ListItemType.EditItem; } else if (itemIndex == selectedIndex) { itemType = ListItemType.SelectedItem; } else if ((itemIndex % 2) != 0) { itemType = ListItemType.AlternatingItem; } DataListItem item = this.CreateItem(itemIndex, itemType, useDataSource, obj2); this.itemsArray.Add(item); if (flag) { this.CreateItem(itemIndex, ListItemType.Separator, useDataSource, null); } dataItemCount++; itemIndex++; } if (this.footerTemplate != null) { this.CreateItem(-1, ListItemType.Footer, useDataSource, null); } } if (useDataSource) { this.ViewState["_!ItemCount"] = (data != null) ? dataItemCount : -1; } }