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

GridViewDecimalColumn problem

1 Answer 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fabien
Top achievements
Rank 2
Fabien asked on 01 Apr 2009, 04:30 PM
Hi,

I have a problem with GridViewDecimalColumn.

Current scenario :
 A) Value = 5
 B) User delete value in cell
 C) User provoque endEdit
 D) Value = DBNull
 E) application crash (not because of telerik)

My need :
 A) Value = 5
 B) User delete value in cell
 C) User provoque endEdit
 D) Value = DBNull, so it's not valid
 E) Value = 5

My question is, is there a way, when a cell == DBNull, to retrieve previous value? I tried the "Close editor when validation failed" but it crash again.

Best regards,

Fabien

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 02 Apr 2009, 03:36 PM
Hello Fabien,

Thank you for your question. Currently you cannot implement your scenario using the validation API, but you can use CellEndEdit and CellBeginEdit to perform the validation. Here is the code that you need:

 private void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e) 
        { 
          if (this.radGridView1.ActiveEditor is GridSpinEditor) 
            { 
                if (this.radGridView1.ActiveEditor.Value == null
                { 
                    this.radGridView1.CurrentCell.Value= oldValue; 
                } 
            } 
        } 
 
        object oldValue;
 
       
        private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) 
        { 
            oldValue = this.radGridView1.CurrentCell.Value; 
        } 

Do not hesitate to write me back if you have further questions.

All the best,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Fabien
Top achievements
Rank 2
Answers by
Nick
Telerik team
Share this question
or