Hi,
I have this template column which is calculating and showing the result of cost x quantity or alternatively quantity x Alternative Cost.
I would like to make this column sortable by clicking on the header but all I have tried up to now does not work.
I have tried to set the SortExpression but still does not sort, the header gets activated but there is no sorting.
Any help will be appreciated.
Thanks,
Felice
I have this template column which is calculating and showing the result of cost x quantity or alternatively quantity x Alternative Cost.
I would like to make this column sortable by clicking on the header but all I have tried up to now does not work.
I have tried to set the SortExpression but still does not sort, the header gets activated but there is no sorting.
Any help will be appreciated.
Thanks,
Felice
<telerik:GridTemplateColumn FilterControlAltText="Filter TotalCost column" HeaderText="Total Cost" UniqueName="TotalCost"> <HeaderStyle Width="70px" /> <ItemStyle HorizontalAlign="Right" /></telerik:GridTemplateColumn>protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridDataItem) { #region Calculate Total Cost //Get the special cost. If the value does not exist, it means the special cost is 0 double specialcost = ((cell.Text.Trim()) != " " && !String.IsNullOrWhiteSpace(cell.Text.Trim())) ? double.Parse(cell.Text.Trim()) : 0; double cost = ((dataBoundItem["Cost"].Text.Trim()) != " " && !String.IsNullOrWhiteSpace(dataBoundItem["Cost"].Text.Trim())) ? double.Parse(dataBoundItem["Cost"].Text.Trim()) : 0; //If the special cost is 0 than total cost = cost * quantity if (specialcost == 0) { dataBoundItem["TotalCost"].Text = (cost * (Convert.ToDouble(dataBoundItem["Quantity"].Text))).ToString("N0"); } else //If special cost exists than total cost = special cost * quantity { dataBoundItem["TotalCost"].Text = ((Convert.ToDouble(dataBoundItem["AlternCost"].Text)) * (Convert.ToDouble(dataBoundItem["Quantity"].Text))).ToString("N0"); } #endregion}}