I have custom list. with calculated column Department Group.
Department group column takes first left letter of title columns in uppercase.
using SPListItemCollection I'm able to get all items. but now I am trying to bind the group record in different table.
example:
all record of Department group : A in one table
all record of Department group : B in one table
so I think for that I need grouping for in SPListItemCollection
I am stuck here help me.
my sample code
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList(listName);
if (list != null) {
SPQuery query = new SPQuery();
query.Query = " <Where>"+
"<IsNotNull>"+
"<FieldRef Name='DepartmentGroup' />"+
"</IsNotNull>"+
"</Where>"+
"<OrderBy>"+
"<FieldRef Name='DepartmentGroup' Ascending='True' />"+
"</OrderBy>";
SPListItemCollection items = list.GetItems(query);
GroupBy
won't be helpful if you are looking for making it to different tables.