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 


0
Ray
9/1/2010 11:04:25 AM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

2 Replies
572 Views

Similar Articles

[PageSpeed] 9

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

"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
> 


0
SAL
9/1/2010 4:42:15 PM
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(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
>
> "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
>>
>
> 


0
Ray
9/1/2010 5:17:03 PM
Reply:

Similar Artilces: