DataList 中FooterTemplate 中控件的值

    技术2022-05-20  39

    MSDN中只有绑定到数据源的项才包含在 Items 集合中。页眉、页脚和分隔符不包含在该集合中。

    因此在想取得DataList的FooterTemplate中控件只能通过以下方法:

            DataListItem footer = null;        foreach (Control item in dlLatestFood.Controls)        {            if (item is DataListItem)            {                footer = item as DataListItem;                if(footer !=null  && footer.ItemType ==ListItemType .Footer)                    footer.FindControl("lblIndex") //此时的footer就是页脚对象

                }        }

     


    最新回复(0)