title: How to sort custom column in a telerik radgrid
body: <p>I have a telerik radgrid with a custom column. The column displays a small icon when a certain condition is met(in case a hidden column has value).
  The current sort works well for all normal columns but I get the usual "server cannot parse data" error when trying to sort the custom </p>
  
  <p>Here is the radgrid code:</p>
  
  <pre><code>    &lt;telerik:RadGrid  
              AllowSorting="true"   
              AllowPaging="True"   
              OnSortCommand="ResultGrid_Validazioni_SortCommand" 
              ID="ResultGrid_Validazioni" 
              runat="server" 
              AutoGenerateColumns="False" 
              CellPadding="0"  
              PageSize="10"
              OnPageIndexChanged="ResultGrid_Validazioni_PageIndexChanged"
              PageSizeChanged="ResultGrid_Validazioni_PageSizeChanged" 
              OnSelectedIndexChanged="ResultGrid_Validazioni_SelectedIndexChanged"
              EnableEmbeddedSkins="false"                      
              Skin="GridMetroEB"
              OnItemDataBound="ResultGrid_Validazioni_ItemDataBound"
              &gt;
              &lt;SortingSettings SortToolTip="Premi qui per ordinare" SortedAscToolTip="Ordinamento crescente" SortedDescToolTip="Ordinamento decrescente" /&gt;
  
          &lt;MasterTableView AllowMultiColumnSorting="true" &gt;
              &lt;NoRecordsTemplate&gt;
                  &lt;b&gt; &amp;nbsp &lt;/b&gt;
              &lt;/NoRecordsTemplate&gt;
              &lt;Columns&gt;
                  &lt;telerik:GridBoundColumn UniqueName="RefKeyFonte" HeaderText="RefKeyFonte" DataField="RefKeyFonte" Display="false"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="CodiceCompagnia" HeaderText="CodiceCompagnia" DataField="Compagnia" Display="false"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="CodiceEnte" HeaderText="CodiceEnte" DataField="Ente" Display="false"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="CodiceSubEnte" HeaderText="CodiceSubEnte" DataField="SubEnte" Display="false"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="TipoDaValidare" HeaderText="TipoDaValidare" DataField="TipoDaValidare" Display="false"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="PuntoVendita" HeaderText="Punto Vendita" DataField="PuntoVendita" &gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="Descrizione" HeaderText="Descrizione" DataField="Description" &gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="TipoValidazione" HeaderText="Tipo Validazione" DataField="TipoValidazione"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="DataInserimento" HeaderText="Data Inserimento" DataField="DataInserimento"&gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="DataUltimaOperazione" HeaderText="Data Ultima Operazione" DataField="DataUltimaOperazione" &gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="DataUltimaValidazione" HeaderText="Data Ultima Validazione" DataField="DataPrecedenteApprovazione" &gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="Stato" HeaderText="Stato" DataField="Stato" &gt;&lt;/telerik:GridBoundColumn&gt;
  
                  &lt;telerik:GridTemplateColumn HeaderText="Nota" SortExpression="Nota"&gt;
                    &lt;ItemTemplate&gt;
                      &lt;asp:ImageButton ID="btn_Nota" ImageUrl="../i/ElementiBase/Pad_25px.gif" OnClick="btn_Nota_Click" runat="server" Enabled="false"/&gt;
                    &lt;/ItemTemplate&gt;
                  &lt;/telerik:GridTemplateColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="Note" HeaderText="Note" DataField="Note" Display="false" &gt;&lt;/telerik:GridBoundColumn&gt;
                  &lt;telerik:GridBoundColumn UniqueName="HasEsito" HeaderText="HasEsito" DataField="HasEsito" Display="false"&gt;&lt;/telerik:GridBoundColumn&gt;
              &lt;/Columns&gt;
          &lt;/MasterTableView&gt;
          &lt;ClientSettings Selecting-AllowRowSelect="True" EnablePostBackOnRowClick="True"&gt;
              &lt;ClientEvents OnRowClick="OnRowSelectingValidazioni" &gt;&lt;/ClientEvents&gt;
  
              &lt;/ClientSettings&gt;
      &lt;/telerik:RadGrid&gt;
  </code></pre>
  
  <p>And here is the code that does the usual sorting:</p>
  
  <pre><code>    protected void ResultGrid_Validazioni_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)
      {
          RadGrid target = source as RadGrid;
          IWFCachedSearch searchProvider = CachedSearchProvider.GetWFCachedSearch(target.ID);
  
          List&lt;Infrastructure.Helpers.SortingExp&gt; sortingExp = new List&lt;Infrastructure.Helpers.SortingExp&gt;();
  
          foreach (GridSortExpression s in (source as RadGrid).MasterTableView.SortExpressions)
          {
              Infrastructure.Helpers.SortingExp sx = new Infrastructure.Helpers.SortingExp();
              sx.FieldName = s.FieldName;
              sx.SortDirection = s.SortOrderAsString();
  
              sortingExp.Add(sx);
          }
  
          // A Command could be fired also for a changed sort order.
          var sl = (from Infrastructure.Helpers.SortingExp s in sortingExp where s.FieldName == e.SortExpression select s).SingleOrDefault();
  
          if (sl != null)
          {
              sl.SortDirection = e.NewSortOrder.ToString();
          }
          else
          {
              Infrastructure.Helpers.SortingExp sxn = new Infrastructure.Helpers.SortingExp();
              sxn.FieldName = e.SortExpression;
              sxn.SortDirection = e.NewSortOrder.ToString();
              sortingExp.Add(sxn);
          }
  
          target.DataSource = ValidazioneGridFormat(searchProvider.GetData(sortingExp) as IEnumerable&lt;ValidazioneBaseDto&gt;);
          target.DataBind();
      }
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>