This is a migrated thread and some comments may be shown as answers.

Grid data clears on column sort

1 Answer 15 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bhalchandra
Top achievements
Rank 1
Bhalchandra asked on 09 Feb 2012, 04:52 PM
Hi,

I have a grid with all default settings related with Sorting. 
grid's ItemSource property is set to custom List<MyCalss> at run time. 
But when i click on column's header for sorting it clears grid data.


Thanks,
Bala

1 Answer, 1 is accepted

Sort by
0
Bhalchandra
Top achievements
Rank 1
answered on 10 Feb 2012, 05:47 AM
Got the issue.
After leaving the context, i was clearing the data source collection assigned to GridView.ItemSource something like below -

List<MyClass> obj = new List<MyClass>;
try
{
//Populate obj here.
this.gridview.ItemSource = obj;
}
catch(Exception)
{}
finally
{
obj.clear(); // This was the culprit
}
Tags
GridView
Asked by
Bhalchandra
Top achievements
Rank 1
Answers by
Bhalchandra
Top achievements
Rank 1
Share this question
or