【问题标题】:DevExpress Grid View ErrorDevExpress 网格视图错误
【发布时间】:2013-06-21 20:43:38
【问题描述】:

我在 Visual Studio 2010 上使用 DevExpress 的组件 GridView 时遇到问题。

我想做的很简单。我有一个按钮,当它被点击时,我想显示这样的消息:“gridview 中第 0 行的 X 列的值为 Y”。

按钮的代码也很简单:

Protected Sub b_test_Click(ByVal sender As Object, ByVal e As EventArgs) Handles b_test.Click
    Dim aux As String
    aux = t_tickets.GetRowValues(0, "numero_de_ticket").ToString

    MsgBox(aux)
End Sub

这段代码运行良好,但它有一个奇怪的行为。

如果我选择 gridview 中的第一行,它可以正常工作。但是,如果我选择不同的行,单击按钮时会出现以下错误:

System.Data.MissingPrimaryKeyException: A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly

我总是选择第一行。我不知道为什么当我选择不同的行时会出现此错误。

谁能帮帮我?

【问题讨论】:

    标签: aspxgridview


    【解决方案1】:

    我认为您的问题不在于 Click 功能。您正在执行回发,试图在该行没有键时将所选行发送到服务器端。

    您应该检查您的 ASPX 文件以查看 KeyFieldName 并检查数据源标识字段是否是您声明的内容。

    <dx:ASPxGridView runat="server" Id="t_tickets" KeyFieldName="Id">
    ...
    ...
    ...
    </dx:ASPxGridView>
    

    我认为你会发现你的情况是错误的。这意味着您指定为 KeyFieldName 的不是与 Grid 行对应的数据源对象的 Property 成员。 (或者它不是数据源中选择语句的一部分)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-10
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多