Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to clear all items from my datagrid in silverlight 2 and reload it with new items.


Does anyone know how to do that?
Posted
Updated 25-May-11 1:38am
v2
Comments
Mark Salsbery 25-May-11 14:50pm    
Setting the DataGrid's ItemsSource property to null should clear it. Setting that property to a different value should clear it and use the new value.

You haven't shown any further info about how you're providing data for the grid so it's difficult to provide a more specific answer...

Try
MIDL
DataGrid d;
d.ClearValue(DataGrid.ItemsSourceProperty)
 
Share this answer
 
Comments
vinodanand@gmail.com 25-May-11 9:09am    
Sorry its not work . please give any other solution or code
vinodanand@gmail.com 25-May-11 9:09am    
Its not work , please give any other code
It clear the grid but the data source also remove so this is not a good way of doing that.

DataSource1.Clear();

is good way of doing that.
 
Share this answer
 
v2
if your datagrid is bound to a collection, you can try
dataGrid.ItemsSource = null. This will clear the datagrid and collection is nullified.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900