//Get data from SharePoint
SPWeb _web = GetWeb();
SPList list = _web.Lists["List"];
SPQuery query = new SPQuery();
query.Query = "" + _user.Name.Trim()
+ ""
+ selectedYear.Trim() + "";
DataTable dt = list.GetItems(query).GetDataTable();
//Get DataRows
if (dt != null && dt.Rows.Count > 0)
{
//Group the data
var groupedRows = from row in dt.AsEnumerable()
group row by row.Field(dt.Columns["Department"]) into grp
orderby grp.Key
select new
{
Name = grp.Key,
_grp = grp
};
foreach (var grp in groupedRows)
{
AccordionPane currentPane = CreateAccordinHeaderPane(mainacc, grp.Name);
groupedRows.ToList();
List rows = grp._grp.ToList();
AddContentToPane(currentPane, rows);
}
}
DataTable dt = new DataTable();
dt = rows.CopyToDataTable(); -> Gets