我有一个asp:Repeater,它有一个自定义集合的DataSourceID。集合类具有我希望在FooterTemplate中显示的属性。因为它是根据所有项目来计算值的。
在FooterTemplate中,是否有访问实际集合对象的方法?可能使用Container或Eval。
我无法直接访问数据源。我可以更改代码以将其作为参数,但更愿意找到其他方法。
你能用这样的东西吗?
rpt.DataSource = mydatasource;
rpt.DataBind();
// label in footer
var lblDateTime = rpt.FindControl("lblDateTime") as Label;
if (lblDateTime != null)
{
lblDateTime.Text = mydatasource.First().DateChecked;
}
或者像这个
void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
// Execute the following logic for Footer only.
if (e.Item.ItemType == ListItemType.Footer) {
// put code here to get what you want and show it in the footer
}
}