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

GridView CellValidating

7 Answers 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David McCloskey
Top achievements
Rank 1
David McCloskey asked on 14 Oct 2009, 08:24 PM
I am attempting to use the CellValidating event.  I am encountering two problems.  First e.RowIndex is coming back as a -1 on the a new first row.  The row has been added using data binding.  Question, how can I find what row I am working with.  Second, I attempt to update the value (e.Row.Cells(1).value = "99213"  in a cell to the default, and the data does not show in e.Value.

Respectfully,
Dave

7 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 20 Oct 2009, 06:03 AM
Hi David McCloskey,

Thank you for writing.

You can check if you are validating add new row by using e.Row argument of CellValidating event:

void radGridView1_CellValidating(object sender, CellValidatingEventArgs e)
{
    if (e.Row is GridViewNewRowInfo)
    {
        //do something
    }
}

Unfortunately, CellValidating event does not support changing the validated cell value. We will consider to improve this behavior in some of the feature releases.

Do not hesitate to contact me again if you have other questions.

Best wishes,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Iftakhar
Top achievements
Rank 1
answered on 12 May 2011, 04:20 PM
Hi,

I am using the Q1 2011 release. I want to change the value in cellvalidating event. Is this feature added in the release? If yes then can you please let me know how to do it.

Thanks 
0
Martin Vasilev
Telerik team
answered on 17 May 2011, 03:25 PM
Hi David McCloskey,

Thank you for writing.

You can change the cell value when handling the CellValidating event by using the CurrentCell property. Please consider the following code as example:

void radGridView1_CellValidating(object sender, CellValidatingEventArgs e)
{
    if (MyCondition)
    {
        this.radGridView1.CurrentCell.Value = "Validated Value";
    }
}

Let me know if you have any other questions.

Greetings,
Martin Vasilev
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Iftakhar
Top achievements
Rank 1
answered on 17 May 2011, 03:29 PM
thank you very much.. it helped
0
David McCloskey
Top achievements
Rank 1
answered on 17 May 2011, 05:24 PM
Thank you for the assistance.

Be Well,
Dave
0
Blas
Top achievements
Rank 2
answered on 24 Jun 2011, 08:51 AM
Hi Martin,

The proposed solution works fine when the current cell has not value, but when the cell has value this assignment doesn't work and the old value remains unchanged. Is that possible?

Thank you
Blas
0
Martin Vasilev
Telerik team
answered on 29 Jun 2011, 11:11 AM
Hi Roberto Andrade Olivie,

Thank you for contacting me.

Setting the value of the current cell should work regardless of whether the old value is null or not. Maybe there is something specific in your project, which causes the described undesired behaviour. Please open a new support ticket and send me a small sample project, which demonstrates your scenario. This will help me to investigative your case further and provide you an accurate assistance. 

Best wishes,
Martin Vasilev
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
David McCloskey
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Iftakhar
Top achievements
Rank 1
David McCloskey
Top achievements
Rank 1
Blas
Top achievements
Rank 2
Share this question
or