gpt4 book ai didi

c# - 多个asp :Repeater DataBind

转载 作者:太空宇宙 更新时间:2023-11-03 18:19:19 24 4
gpt4 key购买 nike

我有 90% 的把握我之前已经做到了这一点,但我不记得我是怎么做到的。

我有一个转发器,我想在一个页面上使用两次,因为结构和数据绑定(bind)事件是相同的,但是与转发器的数据绑定(bind)显然不同。

在过去,我相信我将数据源设置在中继器上,然后进行数据绑定(bind),然后再次使用另一个数据源进行相同操作,非常有效:

MyRepeater.DataSource = DataSourceOne;
MyRepeater.DataBind();
MyRepeater.DataSource = DataSourceTwo;
MyRepeater.DataBind();

现在这将在页面上生成两次 html。在这种情况下,有两个列表,其中包含不同的数据。

考虑一下,它可能是使用的数据源类型。在它可能是数据集/表之前,我绑定(bind)到转发器,但这次我使用的是 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,但这也不起作用。

目前所发生的只是第二个数据绑定(bind)正在重新绑定(bind)旧的中继器,而我在页面上只有一个。

有任何想法吗?
提前致谢

最佳答案

您确定过去您没有对一个数据源使用两个中继器吗?

我认为您需要在这里使用两个中继器。

关于c# - 多个asp :Repeater DataBind,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1426350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com