【问题标题】:Update Gridview datatable after update to database更新到数据库后更新 Gridview 数据表
【发布时间】:2020-11-20 08:53:51
【问题描述】:

我有一个带有绑定数据源的 GidView。 GridView 的数据表由一个通过 MySQL 数据库的选择语句填充。

Gridview 中的数据在带有一些文本框和组合框的表单中进行编辑。当我在 GridView 中选择一行时,可以编辑该记录的数据。 编辑完成后,单击按钮后数据将更新。 数据正确保存在数据库中,但在我的 GridView 中,更新数据不可见。当我从数据库中重新填充 GridView 时,编辑的数据是可见的。

我尝试手动编辑数据表中的数据,但数据表中的其他字段没有更新。

Dim intTableRow As Integer

        For i As Integer = 0 To table.Rows.Count - 1
            If table.Rows(i)("artikelId") = intArtikelId Then
                intTableRow = i
                Exit For
            End If
        Next

        table.Rows(intTableRow).BeginEdit()
        If Not GridViewArtikelen.GetRowCellValue(intRow, "certificaatId") Is DBNull.Value Then
            table.Rows(intTableRow)("certificaat_geldig_tot") = DateAdd(DateInterval.Year, CDbl(txtGeldigheidsduurCertificaat.Text), table.Rows(intTableRow)("datum_certificaat"))
            ''table.Rows(intTableRow)("geldigheidsduur") = CDec(Val(txtGeldigheidsduur.Text))
            'table.Rows(intTableRow).EndEdit()
        End If

这是因为我损坏了数据表的数据行还是我出了什么问题?

【问题讨论】:

  • 您使用的是内置的 GridControl EditForm 功能还是您自己定制的编辑表单?
  • 困惑了半天终于搞明白了。当我的表单的最后一个文本字段被聚焦时,GridView 的数据表无法正确更新。该字段中的值变为 0。当我在对数据库执行更新语句之前更改焦点时,一切都很完美。数据表已正确更新。

标签: vb.net gridview devexpress devexpress-windows-ui


【解决方案1】:

困惑了很久才想通。当我的表单的最后一个文本字段被聚焦时,GridView 的数据表无法正确更新。该字段中的值变为 0。当我在对数据库执行更新语句之前更改焦点时,一切都很完美。数据表已正确更新。

【讨论】:

    猜你喜欢
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-19
    • 1970-01-01
    相关资源
    最近更新 更多