GridView CellValidating

8 posts, 0 answers
  1. David McCloskey
    David McCloskey avatar
    5 posts
    Member since:
    Jan 2009

    Posted 14 Oct 2009 Link to this post

    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
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 20 Oct 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Iftakhar
    Iftakhar avatar
    3 posts
    Member since:
    Feb 2011

    Posted 12 May 2011 Link to this post

    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 
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 17 May 2011 Link to this post

    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.
  6. Iftakhar
    Iftakhar avatar
    3 posts
    Member since:
    Feb 2011

    Posted 17 May 2011 Link to this post

    thank you very much.. it helped
  7. David McCloskey
    David McCloskey avatar
    5 posts
    Member since:
    Jan 2009

    Posted 17 May 2011 Link to this post

    Thank you for the assistance.

    Be Well,
    Dave
  8. Blas
    Blas avatar
    55 posts
    Member since:
    Dec 2007

    Posted 24 Jun 2011 Link to this post

    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
  9. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 29 Jun 2011 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready