首页 新闻 赞助 找找看

asp.net(3)

0
[已解决问题] 解决于 2015-02-24 21:23

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);//Item和Alter交替创建 

        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;//给ViewState的ItemCount赋值 

} 

}
能不能给我详细解释一下上面代码的意思?

博学多思的主页 博学多思 | 初学一级 | 园豆:76
提问于:2015-01-22 21:23
< >
分享
最佳答案
0

哪句你看不懂???比如CreateItem这个方法,你就看看他定义的参数啊,慢慢来嘛

奖励园豆:5
隔壁老王来了 | 初学一级 |园豆:99 | 2015-01-22 21:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册