Wednesday, August 1, 2007

Clearing Items in Repeater (or other) Control in .Net 2.0

You might notice that a repeater does not have an Items.Remove() or an Items.Clear() or even an Items[i].Remove() where you can loop through the collection and remove them one at a time. Nope, clearing a repeater is even easier than that.

I have a search control that dumps the results in a repeater, and to clear the results between search, I use the following line in my search click event:

myRepeater.DataSource = null;

whoop there it is :)


Chris Coddington said...

What if I want do delete just one item in a list of 50?

Andy said...

Deleting the item from the datasource and rebinding would work, right?

tenax_technologies said...

Thanks for sharing.

Tenax Technologies is a Belarussian software development company delivering complex web solutions. We provide comprehensive Java development of complex internet systems.
software company

mumtaz said...

Nice information shared.Thanks a lot for this useful blog.
web designing company

aparna john said...

Hi,You will also want to put photos on your web page. This type of Web Design Cochin can be accomplished with just about any type of web page design program.Thanks......