RowValidating not firing

15 posts, 0 answers
  1. mtaber
    mtaber avatar
    12 posts
    Member since:
    Oct 2006

    Posted 03 Jan 2010 Link to this post

    I have a Grid that is editable by the user and I've got almost everything working. The problem I've run into is that I have this grid on a form that the user can click a button on and close the form. If the user clicks on a textbox column and edits the value, then clicks directly on the "Ok" button to close the form, the data is not validated via the RowValidating event.

    Both the CellFormatting event is called, but apparently the RowValidating event isn't and neither is the CellEndEdit event. However, the DataTable that the grid is bound to is updated properly. For the time being, what I'm doing is rebinding the DataTable to the grid. This works in some cases, but I end up doing my validation after the data has been saved into the DataTable, and by that point it's too late and messes up my data.

    Is there a way for me to manually fire the Validation code? I don't see an easy way to force it to be called in a way that is going to intercept something like this because it seems to bypass all of my validation code.
  2. mtaber
    mtaber avatar
    12 posts
    Member since:
    Oct 2006

    Posted 05 Jan 2010 Link to this post

    Does anyone have any ideas on this?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 07 Jan 2010 Link to this post

    Hi mtaber,

    Thank you for writing.

    I managed to reproduce the described issue with the RowValidating event. We will investigate this further and address it in one of the feature releases. Currently, you can try to use the CellValidating event instead. Please excuse us for the inconvenience.

    I have updated your Telerik points for the report.

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

    All the best,
    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.
  5. Ruth Goldberg
    Ruth Goldberg avatar
    54 posts
    Member since:
    Dec 2009

    Posted 08 Feb 2010 Link to this post

    I had a similar case in my program. In my case, I have a close button and want to allow the user to close the form and save the current record at the same time. Here's how I do it:

    1. I save the current row index.
    2. I either move next or move previous in my binding source, depending on whether or not I'm on the first row. This will cause the cell and row validation events to fire. If my grid has only one row, I don't know how to get the validation events to fire because there is no previous or next row to move to. In this unlikely scenario, I won't save the changed record. 
    3. If the validation fails, I ask the user whether they want to fix the row before closing. If they do, I set cancel to true both for the row validation and the form close. Otherwise, they can just close without saving.
    4. If they want to fix the error, I reset the position of my binding source to the saved row index and don't close the form.

  6. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 10 Feb 2010 Link to this post

    Hello Ruth Goldberg,

    Thank you for sharing your work-around. We are aware of RowValidating issues and we are going to improve this functionality in future. Write us back if you have any other additional questions.

    All the best,
    Martin Vasilev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Shulla Krous
    Shulla Krous avatar
    13 posts
    Member since:
    Oct 2009

    Posted 23 Mar 2010 Link to this post

    Hallo,

     

    I have come across the same problem that the RowValidating event does not fire.

    Your suggestion to use The CellValidating event cannot be a substitute for the RowValidating event.

    For Example, in these cases I must validate cells when the user finishes to enter the whole data into a record:

    1.       Comparing two cells (check if one date greater than other)

    2.       Check for required fields.

     

    The issue is very urgent.

    Do you have a better solution, or is the bug going to be solved in the close future?

     

    Thanks,

    Kr,Kr,

  8. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 25 Mar 2010 Link to this post

    Hello kr kr,

    Thank you for writing.

    Unfortunately, there is not a very clean work-around for the RowValidating issues. Currently, we are working on a major RadGridView revision, which will bring a lot of improvements and new features including validating scenarios. Our plans are to introduce this for the next major release Q2 2010. I am sorry for not being able to help at this time.
     

    Regards,
    Martin Vasilev
    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.
  9. JustinWong
    JustinWong avatar
    147 posts
    Member since:
    Mar 2007

    Posted 10 May 2010 Link to this post

    Hi Kr Kr:

    I'm having the same issue with RowValidating.  Depending on why you've set up selectionmode (row, cell, etc), you could potentially carry out the kind of test you want.

    In my case, I'm not allowing multiple row select, and I have the selection mode set to full row.  So, I know that the row whose cell is be editing is also the row (and the only one) selected.  Then, I can do the kind of compariing you talked about under the ValueChange event of the cell:

        Private Sub RGV_StdEnrl_ValueChanging(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ValueChangingEventArgs) Handles RGV_StdEnrl.ValueChanging
            If TypeOf sender Is Telerik.WinControls.UI.RadTextBoxEditor Then
                Dim ri As GridViewRowInfo = RGV_StdEnrl.SelectedRows(0)
                Dim rte As Telerik.WinControls.UI.RadTextBoxEditor = CType(sender, Telerik.WinControls.UI.RadTextBoxEditor)
                If e.NewValue <> "" Then
                    If IsNumeric(e.NewValue) = False Then
                        MsgBox("Must enter a number")
                        e.Cancel = True
                    ElseIf CInt(e.NewValue) < 0 Or CInt(e.NewValue) > 100 Then
                        MsgBox("Final mark must be between 0 and 100.")
                        e.Cancel = True
                    ElseIf RGV_StdEnrl.Columns("ColAttn").IsVisible AndAlso IsDBNull(ri.Cells("ColAttn").Value) = False Then
                        If e.NewValue > ri.Cells("ColAttn").Value Then
                            MsgBox("Here, I'm comparing the value entered in one cell to the existing value in the cell under the column 'ColAttn'.")
                        End If
                    End If
                End If
            End If
        End Sub

    This seems to work quite well for me. Hope this can help with your situation.

    Regards,

    Justin
  10. Ruth Goldberg
    Ruth Goldberg avatar
    54 posts
    Member since:
    Dec 2009

    Posted 01 Mar 2011 Link to this post

    I am using Q3 2010, but my validation events are still not firing when I leave the grid. I have a header grid with multiple rows and a detail grid which links to the current row of the header that has just a few rows, usually just one. When I made a change in the detail and then moved to the header, the row wasn't validating and not saving (because I do that in the Validated event). I got around this problem by calling the validation events with this code in the leave event:
    Private Sub RadGridViewD_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridViewD.Leave
        'call validation events when we leave the grid if row was modified (won't be called otherwise) 
        If Me.RadGridViewD.CurrentRow IsNot Nothing AndAlso Me.RadGridViewD.CurrentRow.IsModified Then
            Dim ev1 As New RowValidatingEventArgs(Me.RadGridViewD.CurrentRow)
            Me.RadGridViewD_RowValidating(Me.RadGridViewD, ev1)
            If Not ev1.Cancel Then
                Dim ev2 As New RowValidatedEventArgs(Me.RadGridViewD.CurrentRow)
                Me.RadGridViewD_RowValidated(Me.RadGridViewD, ev2)
            End If
        End If
    End Sub
  11. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 04 Mar 2011 Link to this post

    Hello Ruth Goldberg,

    Since I am unable to reproduce described issue with Q3 2010 SP1, could you share some more details on your project? This will help me to investigate your particular case and allow us to address any potential bugs with row validating events for the next releases.

    I look forward to your reply.

    Regards,
    Martin Vasilev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  12. Ruth Goldberg
    Ruth Goldberg avatar
    54 posts
    Member since:
    Dec 2009

    Posted 07 Mar 2011 Link to this post

    This particular form is very complex. It has a pageview. The first page is the main one and is always visible. There is a second page that is invisible until a report is generated, and further report pages that can be generated programmatically. The first page has a selection section on top, header and detail grids below it, and buttons below that. A screen shot is attached with dates selected and some data in the grids. The header grid is empty until the Search button is clicked. Then the grid is filled by a custom header TableAdapter method called FillBySelect that adds the search criteria to the Where clause of the regular Fill method of the header TableAdapter. The detail grid is filled in the header grid's CurrentRowChanged event, by calling the detail TableAdapter Fill method with a record key parameter. Both grids can be edited. Editable columns display in blue, readonly columns in black. The grid also has multicolumncombo columns, which can be filtered. There are quite a number of events called for each grid.
    The header grid calls:CellBeginEdit, CellEditorInitialized, CellValidating, CellValueChanged, CurrentRowChanged, GroupSummaryEvaluate, RowsChanged, RowValidated, RowValidating,  and ViewCellFormatting. The detail grid calls CellBeginEdit, CellEditorInitialized,CellEndEdit, CellValidating, RowValidated, RowValidating,  and ViewCellFormatting.
  13. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 10 Mar 2011 Link to this post

    Hi Ruth Goldberg,

    Thank you for the additional details.

    I have tested the RowValidated event once again and it is thrown as expected when RadGridView loses focus. I used Q3 2010 SP1 (2010.3.10.1215) version for my tests. However, looking at your screenshots I see that you have a quite complex scenario, and it is possible that there is something specific which causes the reported issue.

    If I understand you right, you have found a work-around for you case. However, I would still like to investigate the issue further. To do that, I need a sample project, which demonstrates the issue. Could you strip only a part of your code and send it as a small example to allow us looking into this issue? In order to be able to send us your project, you have to open a new support ticket.

    Kind regards,
    Martin Vasilev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  14. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 26 May 2011 Link to this post

    Here I'm with this trying to figure out how to enable a button I disabled and the right place for me was like the RowValidated but as I saw with the version 419 today,  The RowValidated is called only once the GridView loose focus however it's called RowValidated hence it should be fired when the row is validated.
  15. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 31 May 2011 Link to this post

    Hello Marc,

    Thank you for contacting us.

    I am afraid I am not able to understand your scenario very well. Could you please describe your goal in detail? Some sample code would also be helpful here. This will help me to investigate your case further and provide you with 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.
  16. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 31 May 2011 Link to this post

    Oh sorry forget about it.  I was having issues at the time I wrote this but was solved in a support ticket
Back to Top
UI for WinForms is Visual Studio 2017 Ready