【发布时间】:2009-09-15 10:33:35
【问题描述】:
我有 90% 的把握我以前实现过这个,但我不记得我是怎么做到的。
我有一个转发器,我想在一个页面上使用两次,因为结构和数据绑定事件是相同的,但与转发器的数据绑定显然不同。
在过去,我相信我将数据源设置在中继器上,然后进行数据绑定,然后再次使用另一个数据源执行相同操作,非常有效:
MyRepeater.DataSource = DataSourceOne;
MyRepeater.DataBind();
MyRepeater.DataSource = DataSourceTwo;
MyRepeater.DataBind();
现在这将在页面上生成两次 html。在本例中,有两个列表,其中包含不同的数据。
仔细想想,可能是使用的数据源的类型。在它可能是数据集/表之前,我绑定到转发器,但这次我使用的是 ArrayList。
ArrayList Items = new ArrayList();
Items = this.GetMenu(this._ProductsPageID);
this.rep_ProductsPortfolio.ItemDataBound += new RepeaterItemEventHandler(ProdPortItemDataBound);
this.rep_ProductsPortfolio.DataSource = Items;
this.rep_ProductsPortfolio.DataBind();
// Get portfolio
Items = this.GetMenu(this._PortfolioPageID);
this.rep_ProductsPortfolio.ItemDataBound += new RepeaterItemEventHandler(ProdPortItemDataBound);
this.rep_ProductsPortfolio.DataSource = Items;
this.rep_ProductsPortfolio.DataBind();
我也尝试为每个中继器使用不同的 ArrayList,但这也不起作用。
目前所发生的只是第二个数据绑定正在重新绑定旧转发器,而我在页面上只有一个。
有什么想法吗? 提前致谢
【问题讨论】: