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

Binding column with Integer

2 Answers 205 Views
GridView
This is a migrated thread and some comments may be shown as answers.
George Bill
Top achievements
Rank 1
George Bill asked on 29 Jun 2010, 10:13 AM
Hello,

I need help (again) with the RadGridview please.

PROBLEM :
I use a RadGridView to display some informations. And one column have a Binding with an Integer attribute.
When I edit a row, and put a value which is not a number in the cell, my application crash (normal).

I tried to use GridViewMaskedTextBoxColumn with MaskType="Numeric" but it doesn't work or I does not succeed in using it.

CODE :
I have a gridview with an ObservableCollection as ItemSource :
        private ObservableCollection<IRoleUtilisateur> _userRole; 
        public ObservableCollection<IRoleUtilisateur> ListUserRole 
        { 
            get { return _userRole; } 
            set 
            { 
                _userRole = value; 
                OnPropertyChanged("ListUserRole"); 
            } 
        } 

In my RoleUtilisateur class (implements IRoleUtilisateur) I have an Integer :
        private int _rang; 
        public int Rang 
        { 
            get 
            { 
                return _rang; 
            } 
            set 
            { 
                _rang = value; 
            } 
        } 

XAML :
<telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="{Loc rank}" DataMemberBinding="{Binding Rang}" /> 
</telerik:RadGridView.Columns> 
(I deleted all columns except the one with the Binding with Integer attribute)

INFOS :
Visual Studio 2008
.NET Framework 3.5 SP1
Telerik 2010.1.603

How can I do to avoid crashing please ?

If you need more informations, please tell me.
Thank you in advance for your answer.

Regards,
G.B.

2 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 29 Jun 2010, 10:34 AM
Hi George Bill,

That is a very strange issue since we handle such type mismatches internally and no exceptions are thrown. The only way to observe the actual exception that is being handled internally is to allow Visual Studio to break on "Common Language Runtime Exceptions". 

Could you send us an application where the exception can be observed?


Sincerely yours,
Milan
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
George Bill
Top achievements
Rank 1
answered on 29 Jun 2010, 10:57 AM
Sorry for the inconvenience.

I totally forgot the CellValidating method. I have a very bad cast of e.NewValue in int.
So if e.NewValue is not a number, the application crash.

Sorry again, I have been looking for the answer and missing this stupid error for hours.

An thank you, because it's when you ask me for a demo application that I remember the CellValidating
Tags
GridView
Asked by
George Bill
Top achievements
Rank 1
Answers by
Milan
Telerik team
George Bill
Top achievements
Rank 1
Share this question
or