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

Radgridview does not update until row move!

17 Answers 584 Views
GridView
This is a migrated thread and some comments may be shown as answers.
steve
Top achievements
Rank 1
steve asked on 02 Dec 2010, 12:07 AM
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.

17 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 12:25 AM
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
0
steve
Top achievements
Rank 1
answered on 02 Dec 2010, 05:00 AM
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.
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 Dec 2010, 08:30 AM
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
0
steve
Top achievements
Rank 1
answered on 02 Dec 2010, 12:13 PM
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 Dec 2010, 12:56 PM
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
0
steve
Top achievements
Rank 1
answered on 02 Dec 2010, 01:03 PM
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
0
steve
Top achievements
Rank 1
answered on 03 Dec 2010, 04:29 PM
Someone?
0
Richard Slade
Top achievements
Rank 2
answered on 03 Dec 2010, 04:37 PM
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

0
steve
Top achievements
Rank 1
answered on 03 Dec 2010, 04:39 PM
Hi Richard,

Tried that allready, doesnt helps...
0
Richard Slade
Top achievements
Rank 2
answered on 03 Dec 2010, 04:58 PM
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
0
steve
Top achievements
Rank 1
answered on 03 Dec 2010, 05:12 PM
Nope, doesnt works
0
steve
Top achievements
Rank 1
answered on 03 Dec 2010, 05:20 PM
Could you please provide me a sample how you whould update the grid?
I will try to adapt me to that then
0
Julian Benkov
Telerik team
answered on 07 Dec 2010, 02:01 PM
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.
0
Drago
Top achievements
Rank 1
answered on 20 Feb 2017, 09:38 AM

Hi Steve

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

0
Hristo
Telerik team
answered on 20 Feb 2017, 11:00 AM
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.
0
Paul
Top achievements
Rank 1
answered on 30 Nov 2018, 07:16 AM

    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

0
Hristo
Telerik team
answered on 30 Nov 2018, 08:52 AM
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.
Tags
GridView
Asked by
steve
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
steve
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Julian Benkov
Telerik team
Drago
Top achievements
Rank 1
Hristo
Telerik team
Paul
Top achievements
Rank 1
Share this question
or