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

[Solved] 2010 Q1 SP2 DataFormatString

3 Answers 77 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.
Naresh
Top achievements
Rank 1
Naresh asked on 28 Sep 2010, 04:18 PM
Hello,

We just upgraded to SP2 and still can not seem to get the DisplayFormat data attribute to work in RadGridView.

Here is the column definition (the grid is read-only):
<telerik:GridViewDataColumn DataMemberBinding="{Binding PreferredPhone}"/>

Here is the property it is bound to:
        [Display(ShortName = "Preferred Phone", AutoGenerateFilter = false)]
        [DisplayFormat(DataFormatString = "{0:###-###-####}")]
        public string PreferredPhone

The ShortName and AutoGenerateFilter values are being applied while the DataFormatString is not. I have verified that the Upgrade Wizard worked and that the project is now referencing the 2010.2.924.1040 version of the DLL's.

Any ideas why this does not work?

Thank you,
Brian



3 Answers, 1 is accepted

Sort by
0
Naresh
Top achievements
Rank 1
answered on 28 Sep 2010, 04:57 PM
To correct myself, it's 2010 Q2 SP2.
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 01 Oct 2010, 03:17 PM
Hello Brian,

The format string you've provided is applicable only for number types. For example if you change type of the property PreferredPhone to long instead of string everything should work as expected.
You can easily test what cell would display via:

code: string.Format("{0:###-####-####}", "55512341234")
result: "55512341234"
code: string.Format("{0:###-####-####}", 55512341234)
result: "555-1234-1234"

I hope this makes sense.

Best wishes,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Naresh
Top achievements
Rank 1
answered on 01 Oct 2010, 06:22 PM
It was definitely my fault. DataAnnotation formating works great now.

Thanks!
Tags
GridView
Asked by
Naresh
Top achievements
Rank 1
Answers by
Naresh
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or