setting a column value in code for an updatable ViewGrid

R

Ray Porter

Is there a way to set the value for a column in code when a ViewGrid row is
edited? I have a row-last-updated date that is a required audit field in
all our systems (required by data management). I don't really want the user
updating this field as it should always be system controlled. If I create
an editable ViewGrid tied to either an SqlDataSource or an ObjectDataSource,
the field seems to only be updatable by the user. I can set it the first
time by setting the DefaultValue in code but that has no effect after there
is an initial value in the column.

Do I need to completely take over the editing of the data in code?

Thanks,
=================================
Ray Porter
Information Systems
Applications Development Manager
Division of University Advancement
University of North Carolina at Chapel Hill
Phone: (919) 259-9389
Fax: (919) 843-3314
Pager: (919) 216-4218

(e-mail address removed)
http://www.unc.edu/~dragon

Meddle not in the affairs of dragons for thou
art crunchy and taste good with ketchup
 
S

SAL

You could create a business class that your ObjectDataSource is tied to with
an update method and set the date in that Update method.

Example: in this example, I'd have a TasksTable adapter defined in the
Requests dataset and TasksRow would be a member of that dataset.

<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update,
False)> _
Public Function Update(ByVal dr As RequestDS.TasksRow) As Boolean
dr.mYDate = Now()
Dim b As Boolean
Try
Adapter.Update(dr)
b = True
Catch ex As Exception
b = False
End Try
Return b
End Function
 
R

Ray Porter

Thanks. I'll look into that option.

Ray

SAL said:
You could create a business class that your ObjectDataSource is tied to
with an update method and set the date in that Update method.

Example: in this example, I'd have a TasksTable adapter defined in the
Requests dataset and TasksRow would be a member of that dataset.

<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update,
False)> _
Public Function Update(ByVal dr As RequestDS.TasksRow) As Boolean
dr.mYDate = Now()
Dim b As Boolean
Try
Adapter.Update(dr)
b = True
Catch ex As Exception
b = False
End Try
Return b
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top