setting a column value in code for an updatable ViewGrid

Discussion in 'ASP .Net' started by Ray Porter, Sep 1, 2010.

  1. Ray Porter

    Ray Porter Guest

    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


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

    Meddle not in the affairs of dragons for thou
    art crunchy and taste good with ketchup
    Ray Porter, Sep 1, 2010
    #1
    1. Advertising

  2. Ray Porter

    SAL Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    > http://www.unc.edu/~dragon
    >
    > Meddle not in the affairs of dragons for thou
    > art crunchy and taste good with ketchup
    >
    SAL, Sep 1, 2010
    #2
    1. Advertising

  3. Ray Porter

    Ray Porter Guest

    Thanks. I'll look into that option.

    Ray

    "SAL" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    >> 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
    >>
    >>
    >> http://www.unc.edu/~dragon
    >>
    >> Meddle not in the affairs of dragons for thou
    >> art crunchy and taste good with ketchup
    >>

    >
    >
    Ray Porter, Sep 1, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. x
    Replies:
    1
    Views:
    718
    Kevin Spencer
    Nov 6, 2003
  2. Fendi Baba
    Replies:
    1
    Views:
    297
    Alexey Smirnov
    Feb 11, 2007
  3. Greg Smith
    Replies:
    0
    Views:
    532
    Greg Smith
    Apr 12, 2007
  4. Burak Gunay

    How do you Export a Datagrid/ViewGrid to Excel??

    Burak Gunay, Mar 29, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    93
    Burak Gunay
    Mar 29, 2006
  5. Greg Smith
    Replies:
    0
    Views:
    154
    Greg Smith
    Apr 12, 2007
Loading...

Share This Page