title: Retrieve RadGrid cell value in ItemDataBound - "Input string was not in a correct format."
body: <p>I am trying to set a CssClass based on a the comparison of two cell values in my radGrid.  Both cells are formatted for currency <code>{0:c}</code>, so that when I compare them, I have a $ sign in the text string.  I know how to parse a string to remove the $ sign, which is what I am doing.  However, is there a way to get the raw text of the cell prior to formatting, so that I will not have this error?</p>
  
  <p>Here is my code: </p>
  
  <p>ASPX: </p>
  
  <pre><code>                        &lt;telerik:RadGrid ID="rgCISPartsInfo" DataSourceID="dsCISItem" AutoGenerateColumns="False"
                          GridLines="None" AllowPaging="False" OnItemDataBound="rgCISPartsInfo_ItemDataBound" runat="server" Width="676px"&gt;
                          &lt;MasterTableView AllowPaging="False" DataKeyNames="SalesOrderItemId"&gt;
                              &lt;Columns&gt;
                                  &lt;telerik:GridBoundColumn HeaderText="COST" DataField="AverageCostPrice" AllowSorting="false"
                                      DataFormatString="{0:c}" HeaderStyle-HorizontalAlign="right" ItemStyle-HorizontalAlign="right"
                                      HeaderStyle-Width="80px"&gt;
                                  &lt;/telerik:GridBoundColumn&gt;
                                  &lt;telerik:GridBoundColumn DataField="ExtendedCost" HeaderText="X COST" DataFormatString="{0:c}" HeaderStyle-HorizontalAlign="right" 
                                  HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="right"&gt;&lt;/telerik:GridBoundColumn&gt;
                                  &lt;telerik:GridBoundColumn DataField="Weight" HeaderText="WT" HeaderStyle-HorizontalAlign="right" HeaderStyle-Width="80px" 
                                  ItemStyle-HorizontalAlign="right"&gt;&lt;/telerik:GridBoundColumn&gt;
                              &lt;/Columns&gt;
                          &lt;/MasterTableView&gt;
                      &lt;/telerik:RadGrid&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>protected void rgCISPartsInfo_ItemDataBound(object sender, GridItemEventArgs e)
  {
      try
      {
          // only access item if not header or footer cell
          if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem))
          {
              GridDataItem dataItem = e.Item as GridDataItem;
              GridColumn column = rgCISPartsInfo.MasterTableView.GetColumn("AverageCostPrice");
  
              decimal cost = Convert.ToDecimal(dataItem["AverageCostPrice"].Text);
              decimal price = Convert.ToDecimal(dataItem["Price"].Text);
              if (cost &gt; price)
              {
                  dataItem.CssClass = "Grid_Red_Row";
                  throw new Exception("Item Cost is greater than price.");
              }
          }
      }
      catch (Exception ex)
      {
          GlobalHelper.ShowErrorMessage(this.Page.Master, ex.Message);
      }
  }
  </code></pre>
  
  <p>UPDATE:
  The selected solution is the answer to my question, but I ultimately decided to simply parse the string for the $ sign, as it was the simplest solution.</p>