How to dynamically refresh a .NET databound repeater control

Ash Machine picture Ash Machine · Jan 20, 2009 · Viewed 21k times · Source

I have a .NET repeater control that is data-bound to a List. As part of the Repeater's Item Collection, I have a "Remove Button" that effectively removes this current List element.

This works, in code-behind I can successfully remove an item from the datasource of the Repeater.

My problem is this : when I reset the updated datasource and call MyRepeater.DataBind() again, the Repeater interface does not refresh with the Item removed.

I am looking for the event to essentially redraw or refresh the Repeater based on the updated List. Thanks for any pointers or examples.

Answer

Dhaust picture Dhaust · Jan 20, 2009

You need to call the 'DataBind' method on your datasource, then call 'DataBind' on your Repeater control.