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

[Solved] decimal column show as empty string in cell

1 Answer 501 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott Nolen
Top achievements
Rank 1
Scott Nolen asked on 07 Dec 2010, 03:00 AM
I have a column that is bound to a field that is a decimal data type. It defaults to showing a 0(zero) in the column because i have an aggregate function to sum the total in the footer. My users do not want to see a 0(zero) in the column by default but simply as empty. Is there a way that i can display the column as empty instead of the default value of 0(zero) ? Also, if they actually enter a 0(zero) in the column i would want to save a 0(zero) to the database. If the column was left empty i need to detect that and store a null to the database. If a number is entered then store the numeric decimal value.


column binding/set up:

 

 

 

<telerikGridView:GridViewDataColumn Header="Rate" HeaderTextAlignment="Center" TextAlignment="Right" DataMemberBinding="{Binding Rate, Mode=TwoWay}" Width="75" DataFormatString="{}{0:f}" CellStyle="{StaticResource Rev_Cell}" >

 


declaration Rate:

 

 

public decimal Rate { get; set; }


 

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 10 Dec 2010, 05:24 PM
Hi Scott Nolen,

You can accomplish this by having the Rate property of type nullable decimal:

public decimal? Rate {...};

As for the zeroes - you can leverage the CellTemplateSelector.

Find attached a sample project - hope it will get you started.

Best wishes,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Scott Nolen
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or