Group data in dataset based on one column RRS feed

  • Question




    I have dataset with 3 columns Title,Path and Name. Rows in dataset can have same title but different Path and name values.

    The functionality demands to group all the rows based on title, thatis i want to sort rows based on title and place all the rows with same title in different dataset.


    Any help on how to group this data ??




    Wednesday, April 23, 2008 9:35 AM

All replies

  • You could create sorted DataView from your DataTable and then you would need to move rows one-by-one into another DataTable/DataSet. Sortinmg would allow you to distinguish when next set of rows with new title begins.

    Another way is to use next kind of helper class to get distinct values of titles (see sample here ) and then looping through selected distinct values call Select method of your DataTable to select row with specific title and copy them into another DataTable.

    One more potential method is to use LINQ to query data, but you still need to know distinct values for your titles to make proper query.

    Tuesday, April 29, 2008 9:30 AM