This is a migrated thread and some comments may be shown as answers.

RadGrid - question about DataFormatString

1 Answer 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James McQuade
Top achievements
Rank 1
James McQuade asked on 24 Feb 2009, 01:45 AM
I have a column called TradeAmount that is defined as nvarchar(30) in the DB since some of the values are 1MM+  etc.
However, the non-string values have 2 decimal places which I want to remove, for ex -> 1400000.00 needs to be 1400000.
Tried out different DataFormatStrings on the corresponding GridBoundColumn, but none seems to work and the value continues to show the 2 decimal places.

Suggestions?

Thanks
- Arun

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Feb 2009, 07:59 AM
Hello James,

Try the following approach:
<telerik:GridTemplateColumn HeaderText="TEST"
  <ItemTemplate> 
    <%# DoSomething(Eval("EID")) %> 
  </ItemTemplate> 
</telerik:GridTemplateColumn> 

protected string DoSomething(object value) 
  float fvalue; 
  if (float.TryParse(value.ToString(), out fvalue)) 
    return fvalue.ToString("#"); 
  return value.ToString(); 

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
James McQuade
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or