Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   setting a column value in code for an updatable ViewGrid (http://www.velocityreviews.com/forums/t732268-setting-a-column-value-in-code-for-an-updatable-viewgrid.html)

Ray Porter 09-01-2010 11:04 AM

setting a column value in code for an updatable ViewGrid
 
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

ray_porter@unc.edu
http://www.unc.edu/~dragon

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



SAL 09-01-2010 04:42 PM

Re: setting a column value in code for an updatable ViewGrid
 
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(S ystem.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

"Ray Porter" <ray_porter@unc.edu> wrote in message
news:uXb1xVcSLHA.620@TK2MSFTNGP06.phx.gbl...
> 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
>
> ray_porter@unc.edu
> http://www.unc.edu/~dragon
>
> Meddle not in the affairs of dragons for thou
> art crunchy and taste good with ketchup
>




Ray Porter 09-01-2010 05:17 PM

Re: setting a column value in code for an updatable ViewGrid
 
Thanks. I'll look into that option.

Ray

"SAL" <SAL@nospam.nospam> wrote in message
news:%23sMAjSfSLHA.2068@TK2MSFTNGP05.phx.gbl...
> 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(S ystem.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
>
> "Ray Porter" <ray_porter@unc.edu> wrote in message
> news:uXb1xVcSLHA.620@TK2MSFTNGP06.phx.gbl...
>> 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
>>
>> ray_porter@unc.edu
>> http://www.unc.edu/~dragon
>>
>> Meddle not in the affairs of dragons for thou
>> art crunchy and taste good with ketchup
>>

>
>





All times are GMT. The time now is 05:08 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.