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

Blank numeric cells support with autogenerated columns

2 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ColinBlakey
Top achievements
Rank 2
ColinBlakey asked on 12 Apr 2013, 01:39 PM
I have the same issue to that mentioned in the following forum post (Validating blank numeric cells ) the only difference being that all of my columns are auto generated so I cannot apply the datamemberbinding xaml solution. I'm presuming that I will need to apply it in my AutoGeneratingColumn code block but I'm just not sure how. Any help/example would be appreciated.

Thanks
Colin

2 Answers, 1 is accepted

Sort by
0
ColinBlakey
Top achievements
Rank 2
answered on 12 Apr 2013, 02:31 PM
To answer my own question I managed to search on the correct terms and found code that worked.

The solution is fairly simple, in the AutoGeneratingColumn handler code you need to replace the current binding with a new binding to the a null value converter (see the link in my questin above for an example) that handles null values. In my case the code is as

var column = e.Column as GridViewDataColumn;
 
// Code to figure out if it's the correct column....
 
// New binding to the null value converter, taking the existing binding path
var nullValueBinding = new Binding(column.DataMemberBinding.Path.Path)
{
    Mode = BindingMode.TwoWay,
    Converter = new NullNumericConverter()
 
};
 
column.DataMemberBinding = nullValueBinding;

Colin
0
Dimitrina
Telerik team
answered on 12 Apr 2013, 03:32 PM
Hello Colin,

I am glad you have resolved the issue. Thank you for sharing the solution with the community. 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
ColinBlakey
Top achievements
Rank 2
Answers by
ColinBlakey
Top achievements
Rank 2
Dimitrina
Telerik team
Share this question
or