我90%確定我已經完成了此操作,但我不記得我是如何做到的。多個asp:轉發器DataBind
我有一箇中繼器,我想在頁面上使用兩次,因爲結構和數據綁定事件是相同的,但與中繼器的數據綁定明顯不同。
在過去,我相信我重新設置中繼器上的數據源,然後databinded,然後做相同,但與其他數據源,所以有效:
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,但那也不起作用。
目前發生的所有事情都是第二個數據綁定重新綁定到舊的中繼器上,並且我只在頁面上有一個數據綁定。
任何想法? 在此先感謝
我如何使用嵌套中繼器爲我的問題在這裏:http://stackoverflow.com/questions/31255119/how-to-populate-two-separate-repeaters-with-distinct-column-name-and-該值-c – SearchForKnowledge 2015-07-07 13:39:20