2009-08-25 92 views
1

我有一個devXpress GridView,並有一個功能來編輯特定的行。我有兩列名爲「dateModified」和「modifiedBy」。我希望當有人點擊「編輯」按鈕時,它會自動用當前日期和用戶填充這兩個字段。有沒有辦法在客戶端代碼中執行此操作?AspxGridview更新行默認值

這是我走到這一步,但它似乎並沒有做什麼,我想:

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 

當我測試了它,它給了我這個錯誤:

No default member found for type

任何想法關於如何讓用戶在編輯時顯示默認值?

更新:修正,請參閱下面的解決方案

回答

1

其他任何人有這個問題,這是怎麼得到它的工作:

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 
+0

謝謝,這是有益的 – SharpAffair 2010-03-25 17:10:20