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

Formatting a GridBoundColumn

2 Answers 636 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Jul 2011, 07:40 PM
Hi,

I was wondering if it is to possible to make some "advance" formatting on a GridBoundColumn. In fact, I want to show a number with always and only one digit (ex : 197,1 - 197,0 - 197,8). The best I come to is to show a digit if this digit isn't a 0 (so, it look like 197,1 - 197 - 197,8). I try with a GridNumericColumn,but no luck. So, here is my code 

<telerik:GridBoundColumn DataField="test" HeaderText="test" UniqueName="test"
DataFormatString="{0:$###.#}" />

Is anyone may help me please ?

Thank you,
David

PS: I'm now wondering if it is a better solution if I just override the DataFormatString propriety, cause I'm now using a override GridTemplateColumn, so I will just have to plug the override propriety in. So, if anyone know how to correctly override DataFormatString, please let's me know how.

2 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 13 Jul 2011, 09:20 AM
Hello David,

DataFormatString should work fine for formatting the value. If you have some problems, you could test it with DataBinder.Eval in a template column. If it works with Eval, then we could surch for problems with non-applying the format string from DataFormatString property.

<telerik:GridTemplateColumn>
    <ItemTemplate>
        <%# Eval("test", "value of 'test' is: {0:f2} ")%>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Also make that database field is correct type. It should be decimal or real

Kind regards,
Vasil
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
David
Top achievements
Rank 1
answered on 13 Jul 2011, 01:59 PM
Hey,

Thank you
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Vasil
Telerik team
David
Top achievements
Rank 1
Share this question
or