Hi,
I have a grid that's grouped by days of the week. What I would like is to group by specific categories, for example; today, yesterday. All entries for today's date grouped in "Today", all entries for yesterday grouped in "Yesterday" but I'm not sure how. Currently the grid is grouped by every new date. Can I manually set this up in code? I attached a screen shot of my current grid and here is the code for my most recent attempt:
I have a grid that's grouped by days of the week. What I would like is to group by specific categories, for example; today, yesterday. All entries for today's date grouped in "Today", all entries for yesterday grouped in "Yesterday" but I'm not sure how. Currently the grid is grouped by every new date. Can I manually set this up in code? I attached a screen shot of my current grid and here is the code for my most recent attempt:
protected void RadGrid2_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { this.grdRecentActivity.MasterTableView.GroupsDefaultExpanded = false; if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; DataRowView groupDataRow = (DataRowView)e.Item.DataItem; DateTime currentdate = DateTime.Now.Date; DateTime yesterdaysDate = DateTime.Now.AddDays(-1).Date; DateTime dayBeforeYesterday = DateTime.Now.AddDays(-2).Date; DateTime activityDate = DateTime.Parse(groupDataRow.Row.ItemArray[0].ToString()); if (activityDate == currentdate) item.DataCell.Text = "Today"; if (activityDate == yesterdaysDate) item.DataCell.Text = "Yesterday"; if (activityDate == dayBeforeYesterday) item.DataCell.Text = "Day Before Yesterday"; //item.DataCell.Text = groupDataRow.Row.ItemArray[0]; } }