Prev: How to create a simple url to access an intranet
Next: Procedure timeout when executing from the ASP.NET application
From: Ray Porter on 1 Sep 2010 07:04 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(a)unc.edu http://www.unc.edu/~dragon Meddle not in the affairs of dragons for thou art crunchy and taste good with ketchup
From: SAL on 1 Sep 2010 12:42 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(a)unc.edu> wrote in message news:uXb1xVcSLHA.620(a)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(a)unc.edu > http://www.unc.edu/~dragon > > Meddle not in the affairs of dragons for thou > art crunchy and taste good with ketchup >
From: Ray Porter on 1 Sep 2010 13:17
Thanks. I'll look into that option. Ray "SAL" <SAL(a)nospam.nospam> wrote in message news:%23sMAjSfSLHA.2068(a)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(a)unc.edu> wrote in message > news:uXb1xVcSLHA.620(a)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(a)unc.edu >> http://www.unc.edu/~dragon >> >> Meddle not in the affairs of dragons for thou >> art crunchy and taste good with ketchup >> > > |