0

How to group data of Listview when data are bind from SQL Database

I used Collection View Source for that but it is not working

My Code lines are mentioned below :

    CollectionViewSource viewSource = new CollectionViewSource { Source = ds };
    viewSource.GroupDescriptions.Add(new PropertyGroupDescription("RequestID"));
    ListView1.ItemsSource = viewSource.View;

but it not working properly , even data are not show in listview when Listview Item Source is bind with Collection View Source

Please help me out. Thanks a lot.

1 Answers1

2

you can try the following

ICollectionView view = CollectionViewSource.GetDefaultView(ds);
view.GroupDescriptions.Add(new PropertyGroupDescription("RequestID"));
listview1.ItemsSource = view;

dont forget to set a grouping template. btw here is a related question with an complete anwser.

Community
  • 1
  • 1
blindmeis
  • 22,175
  • 7
  • 55
  • 74