Field Grouping with SPGridView - More than one group returned for a single value
It is very easy to group by a field using the SharePoint SPGridView control. Just set some properties and your good to go.
resultsGridView.GroupField = “Status”;
resultsGridView.GroupFieldDisplayName = “Status”;
resultsGridView.GroupDescriptionField = “Description”;
resultsGridView.AllGroupCollapse = true;
resultsGridView.DisplayGroupFieldName = false;
However, depending on how your results are sorted, you may see that you get multiple groups for a single value. The way to fix this is to sort by the same field you are grouping by.
In this first example, I am grouping by “Status” and sorting only by “DueDate”
In this example, I am still grouping by “Status” but now I am first sorting by “Status” and then by “Due Date”
You may not notice this issue right away. It all depends on the value of your results and how they are sorted. So while it may work right off the bat, later on the issue may pop up!