or
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
Label label = (Label)dataItem.FindControl("DaysInStock");
label.Text =
DateTime.Now.Subtract(DateTime.Parse(dataItem["DateIntoStock"].Text)).Days.ToString();
}
I also want to be able to sort on this column. How can I implement this?
Thanks,
Stuart
Is it possible to control the order of the groups on the grid, or disable grid's ordering mechanism and just display it in the order data is fed to the grid. Unfortunatelly, domain entities are fed directly to the UI and they do not have any meaningful attribute upon which to set the group expression. Here is how the data is being fed to the grid, and I would like the grid not to change the order.
| this.BaseProductBenefitsGrid.DataSource = Benefits |
| .OrderBy(b => |
| { |
| switch (b.BenefitServiceGroup) |
| { |
| case "Inpatient": |
| return 1; |
| case "Outpatient": |
| return 2; |
| case "Other": |
| return 3; |
| } |
| return 4; |
| }).ThenBy(b => b.Type.DisplayOrderNumber).ToList(); |
| BaseProductBenefitsGrid.DataBind(); |
| <GroupByExpressions> |
| <telerik:GridGroupByExpression > |
| <SelectFields > |
| <telerik:GridGroupByField HeaderText="-" FieldName="BenefitServiceGroup" HeaderValueSeparator=" " SortOrder="None" /> |
| </SelectFields> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="BenefitServiceGroup" /> |
| </GroupByFields> |
| </telerik:GridGroupByExpression> |
| </GroupByExpressions> |