I have declared an asp:Repeater on my page with ID="AnswersRepeater". I am calling the below segment of code when the user clicks a button on the page to load additional data from a DataSet denoted as "ds". I need to understand the control hierarchy of an asp:repeater so I can add back in the items the repeater had after rebinding to the datasource like below:
Dim cur开发者_JAVA百科rentItems As New ArrayList(AnswersRepeater.Items)
AnswersRepeater.DataSource = ds
AnswersRepeater.DataBind()
For Each item As RepeaterItem In currentItems
AnswersRepeater.Controls.Add(item)
Next
The problem is, the RepeaterItems are not added in the correct place within the repeater control's hierarchy. I need to find the item template and append the items in currentItems array to it. Any help is much appreciated.
You shouldn't be directly editing the controls of the Repeater control, the idea is you bind to a data source and it dynamically creates controls for you based on that data source.
You'd be better adding the items you already have to your data source ds
and then just binding once.
精彩评论