Radgridview does not update until row move!

18 posts, 0 answers
  1. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 01 Dec 2010 Link to this post

    Hi everyone.

    I have this issue, and i'm trying to deal with it for the last 3 days now, no solution found.
    My grid is loaded using an DataAdapter.

    When I edit the items in the grid,and fire the update command, the data in my database will not be updated.
    This is until i move the grid one row. Then it will accept changes made. So i'm struggeling here to find a way out.

    Could you please provide me some sample or solution for this?
    Btw, i'm using VB.NET for this.
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 01 Dec 2010 Link to this post

    Hi Steve,

    I haven't heard of this situation before to be honest. It sounds very strange. If you could post some code to replicate it, I'll have a look at it first thing for you. In the meantime, I'd suggest wrapping any updates to your grid in

    Using Me.radGridView1.Deferrefresh()
    ' Some update to grid
    End Using

    this may hep, but without seeing an example, it may be tricky to sort out.
    Best regards,
    Richard
  3. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 01 Dec 2010 Link to this post

    I currently use this code:

    Dim cmd As System.Data.Odbc.OdbcCommand
    Dim adp As System.Data.Odbc.OdbcDataAdapter
    Dim ds As New DataSet
    '
    Private Sub FormLoader() Handles MyBase.Load
        cn.Open()
        cmd = New System.Data.Odbc.OdbcCommand("SELECT * FROM TABLE", cn)
        adp = New System.Data.Odbc.OdbcDataAdapter(cmd)
        adp.Fill(ds, "TABLE")
        '
        Me.RadGridView1.AutoGenerateColumns = True
        Me.RadGridView1.DataSource = ds
        Me.RadGridView1.DataMember = "TABLE"
    End Sub
     
    Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click

        Dim cmdbuilder As New System.Data.Odbc.OdbcCommandBuilder(adp)
        Dim i As Integer
     
        i = adp.Update(ds, "TABLE")
        MsgBox("Records Updated= " & i)
    End Sub

    Witch works fine for me. Expect that i always need to change a row before it updates.
    I'm used to working with the VB.NET Datagridview, where this code always did the job like i wanted it to be.

    Thank you for your help.
  4. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 02 Dec 2010 Link to this post

    Hello Steve,

    Are yous still in edit mode while pressing the save button?

    Try calling an EndEdit() or if this failes, try adding a BeginUpdate(); EndUpdate(true) in the first lines of your ButtonClick.

    Please let me know if this works for you.

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  5. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 02 Dec 2010 Link to this post

    Hi.

    Yes, i tryed all of those options, none of them seem to work.
    It seems that for some reason the editor only exits when i move a row.
    Whatever i try, it wont let me update without moving a row.

    Regards
  6. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 02 Dec 2010 Link to this post

    Hello again,

    So it is because the grid is still editing, can you please create a very small project, copy paste here and i will help you solve this problem.

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  7. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 02 Dec 2010 Link to this post

    Hello.

    This is my designer file

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class frm_goederen
       
    * Client requests privacy about his code.

    End Class

    And here is my code:

    Public Class frm_goederen
     
    *Client requests privacy about his code
     
    End Class

    There is a DataSet3 included, but is not used at all.

    When i try the same thing with a REGULAR DataGridView, i use this code:

    Private Sub RadButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadButton1.Click
            DataGridView1.EndEdit()
            UpdateGrid()
        End Sub
     
        Private Sub UpdateGrid()
            Dim cmdbuilder As New System.Data.Odbc.OdbcCommandBuilder(adp2)
            Dim i As Integer
            Try
                i = adp2.Update(ds2, "TABLE")
                MsgBox("Aantal wijzigingen doorgevoerd: " & i, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Success")
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Oeps...")
            End Try
        End Sub

    And it's working the way it should be working.

    So i cant figure it out at all...

    Thank you for your time
  8. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 03 Dec 2010 Link to this post

    Someone?
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 03 Dec 2010 Link to this post

    Hi Steve,

    Sorry about the delay in getting back to you. I haven't been able to run your project at the moment, but may I suggest
    • Disable your button
    • Subscribe to the CellEndEdit event.
    • In there, re-enable your button and give it a click (removing theDataGridView1.EndEdit() line)

    Let me know if that helps at all.
    Richard

  10. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 03 Dec 2010 Link to this post

    Hi Richard,

    Tried that allready, doesnt helps...
  11. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 03 Dec 2010 Link to this post

    Hi Steve,

    This sounds very odd. After you update, please can you also try calling
    Me.RadGridView1.CurrentRow.InvalidateRow()

    We have never expienced this issue before, but I don't have any DB access today as I'm at home so can't try it. Let me know if this help.

    Thanks
    Richard
  12. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 03 Dec 2010 Link to this post

    Nope, doesnt works
  13. steve
    steve avatar
    9 posts
    Member since:
    Nov 2010

    Posted 03 Dec 2010 Link to this post

    Could you please provide me a sample how you whould update the grid?
    I will try to adapt me to that then
  14. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 07 Dec 2010 Link to this post

    Hi steve,

    In this scenario the edit operation depends on the bound object that in your case is DataTable/DataSet. DataRow/DataRowView objects implement IEditableObject and when some data in RadGridView is changed, the internal CurrencyManager calls EndEdit of current item after the current position is changed to another row.

    If you want to apply your changes immediately, you can use following code snippet:

    Dim editableObject As IEditableObject = TryCast(Me.radGridView1.CurrentRow.DataBoundItem, IEditableObject)
    If editableObject IsNot Nothing Then
        editableObject.EndEdit()
    End If

    I hope this helps.

     

    Greetings,
    Julian Benkov
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  15. Drago
    Drago avatar
    1 posts
    Member since:
    Feb 2017

    Posted 20 Feb 2017 in reply to steve Link to this post

    Hi Steve

    I faced with sam problem as you. Have you figured out how to fixit? 

  16. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 20 Feb 2017 Link to this post

    Hi Drago,

    Thank you for writing.

    We have a documentation article providing examples how the database can be updated handling various scenarios: https://feedback.telerik.com/Project/154/Feedback/Details/203285-fix-radgridview-the-last-row-is-not-updated-when-the-grid-is-bound-to-ieditabl.

    In case you are using an older version of the controls you can check the following feedback item. The issue was resolved in the R3 2016 SP1 version of the suite.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  17. Paul
    Paul avatar
    1 posts
    Member since:
    Nov 2018

    Posted 30 Nov 2018 in reply to Hristo Link to this post

        dgErrors.ClearSelection()
        dgErrors.CurrentCell = Nothing

     

    this worked for me, though i didnt try any of the other suggestions.

    It effectively moves your selected row , and the problems goes away

  18. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 30 Nov 2018 Link to this post

    Hello Paul,

    Thank you for updating the thread and for sharing your solution. I hope that it will help the community.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top