AspxGridview 更新行默认值

发布于 2024-08-03 02:53:25 字数 692 浏览 4 评论 0原文

我有一个 devXpress Gridview,并且有一个编辑特定行的功能。我有两列,名为“dateModified”和“modifiedBy”。我希望每当有人单击“编辑”按钮时它都会自动用当前日期和用户填充这两个字段。有没有办法在客户端代码中执行此操作?

这是我到目前为止所得到的,但它似乎没有达到我想要的效果:

Protected Sub ASPxGridView1_UpdateRow(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs) Handles grid.StartRowEditing
    Dim currentTime As Date = System.DateTime.Today

    e.EditingKeyValue("date_modified") = Format(currentTime, "MM/dd/yyyy")
    e.EditingKeyValue("modified_by") = Environment.UserName
End Sub

当我测试它时,它给了我这个错误:

找不到该类型的默认成员

关于如何在用户编辑时显示默认值有什么想法吗?

更新:已修复,解决方案见下文

I have a devXpress Gridview and there's a functionality to edit specific rows. I have two columns called "dateModified" and "modifiedBy". I want it to automatically populate those two fields with the current date and user whenever somebody clicks the "edit" button. Is there a way to do this in the client code?

This is what I got so far but it doesn't seem to do what I want:

Protected Sub ASPxGridView1_UpdateRow(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs) Handles grid.StartRowEditing
    Dim currentTime As Date = System.DateTime.Today

    e.EditingKeyValue("date_modified") = Format(currentTime, "MM/dd/yyyy")
    e.EditingKeyValue("modified_by") = Environment.UserName
End Sub

When I tested it, it gave me this error:

No default member found for type

Any ideas on how I can get the default values to show up when the user is editing?

Update: Fixed, see below for solution

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然#的苍凉 2024-08-10 02:53:25

对于遇到此问题的其他人,以下是使其正常工作的方法:

Protected Sub ASPxGridView1_UpdateRow(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs) Handles grid.StartRowEditing
    Dim currentTime As Date = System.DateTime.Today
    grid.GetDataRow(grid.EditingRowVisibleIndex()).Item("date_modified") = Format(currentTime, "MM/dd/yyyy")
    grid.GetDataRow(grid.EditingRowVisibleIndex()).Item("modified_by") = Environment.UserName
End Sub

For anyone else having this problem, this is how to get it to work:

Protected Sub ASPxGridView1_UpdateRow(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxStartRowEditingEventArgs) Handles grid.StartRowEditing
    Dim currentTime As Date = System.DateTime.Today
    grid.GetDataRow(grid.EditingRowVisibleIndex()).Item("date_modified") = Format(currentTime, "MM/dd/yyyy")
    grid.GetDataRow(grid.EditingRowVisibleIndex()).Item("modified_by") = Environment.UserName
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文