本文整理汇总了C#中System.Web.UI.Control.ClearChildState方法的典型用法代码示例。如果您正苦于以下问题:C# Control.ClearChildState方法的具体用法?C# Control.ClearChildState怎么用?C# Control.ClearChildState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.Control
的用法示例。
在下文中一共展示了Control.ClearChildState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDataBinding
// Override to create the repeated items from the DataSource.
protected override void OnDataBinding(EventArgs e) {
base.OnDataBinding(e);
if (DataSource != null) {
// Clear any existing child controls.
Controls.Clear();
// Clear any previous state for the existing child controls.
ClearChildState();
// Iterate over the DataSource, creating a new item for each data item.
IEnumerator dataEnum = DataSource.GetEnumerator();
int i = 0;
while(dataEnum.MoveNext()) {
// Create an item.
RepeaterItem item = new RepeaterItem(i, dataEnum.Current);
// Initialize the item from the template.
ItemTemplate.InstantiateIn(item);
// Add the item to the ControlCollection.
Controls.Add(item);
i++;
}
// Prevent child controls from being created again.
ChildControlsCreated = true;
// Store the number of items created in view state for postback scenarios.
ViewState["NumItems"] = i;
}
}