tags:

views:

1432

answers:

1

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

+1  A: 

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
Mike
Thanks, that was helpful
Sphynx