objectdatasource

Discussion in 'ASP .Net' started by germ, Jan 31, 2010.

  1. germ

    germ Guest

    I really like the objectdata source with one notable exception.
    When doing an update, a new() object is created and the bound values on the
    form used to set its properties with all other properties set to default
    values.
    I would like to be able to override the object creation step and provide a
    copy of the original object to be updated such that all values are set not
    just those that were bound on the form.

    As far as I can tell there is no way to do this - am I missing something and
    this is possible ?

    Gerry
     
    germ, Jan 31, 2010
    #1
    1. Advertising

  2. Hi Gerry,

    From your description, I understand that you want to get the copy of
    original data and only change the value needed to be changed while updating
    with ObjactDataSource control, right? If I have misunderstood you, please
    feel free to let me know.

    To get original data, you can save it in ViewState in ObjectDataSource's
    Selected event and retrieve it in Updating event and then modify it.

    For more information, see

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    source.updating.aspx
    http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    06-cs.aspx


    I look forward to receiving your test results.


    --
    Best Regards,
    Thomas Sun

    Microsoft Online Partner Support

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
    to the limited number of phone-based technical support incidents. Complex
    issues or server-down situations are not recommended for the newsgroups.
    Issues of this nature are best handled working with a Microsoft Support
    Engineer using one of your phone-based incidents.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    | From: "germ" <>
    | Subject: objectdatasource
    | Date: Sun, 31 Jan 2010 09:31:00 -0500
    | Lines: 15
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com 206.248.138.28
    | Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    | Xref: TK2MSFTNGHUB02.phx.gbl
    microsoft.public.dotnet.framework.aspnet:96142
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | I really like the objectdata source with one notable exception.
    | When doing an update, a new() object is created and the bound values on
    the
    | form used to set its properties with all other properties set to default
    | values.
    | I would like to be able to override the object creation step and provide
    a
    | copy of the original object to be updated such that all values are set
    not
    | just those that were bound on the form.
    |
    | As far as I can tell there is no way to do this - am I missing something
    and
    | this is possible ?
    |
    | Gerry
    |
    |
    |
    |
     
    Thomas Sun [MSFT], Feb 1, 2010
    #2
    1. Advertising

  3. germ

    germ Guest

    Thanks Thomas,

    This seems to work fine under the specific ODS configuration given in the
    example.
    However, in cases where multiple forms each update a different subset of
    properties on the same data object, we are forced to setup an update method
    specific to each form. I would prefer to configure the ODS on each form
    with the DataObjectTypeName to all invoke the same update method which takes
    the updated data object as its only argument .
    In this scenario, you can't modifiy the InputParameters in the Updating
    event - it generates the runtime error : System.NotSupportedException: The
    OrderedDictionary is readonly and cannot be modified.
    But this is moot anyway because the new object has already been created and
    populated before this point.

    I am thinking that this will involve a custom ObjectDataSource. I may either
    try to track down the source for the ODS or use relector to see if deriving
    from the standard ODS is possible.

    Gerry




    "Thomas Sun [MSFT]" <> wrote in message
    news:...
    > Hi Gerry,
    >
    > From your description, I understand that you want to get the copy of
    > original data and only change the value needed to be changed while
    > updating
    > with ObjactDataSource control, right? If I have misunderstood you, please
    > feel free to let me know.
    >
    > To get original data, you can save it in ViewState in ObjectDataSource's
    > Selected event and retrieve it in Updating event and then modify it.
    >
    > For more information, see
    >
    > http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    > source.updating.aspx
    > http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    > 06-cs.aspx
    >
    >
    > I look forward to receiving your test results.
    >
    >
    > --
    > Best Regards,
    > Thomas Sun
    >
    > Microsoft Online Partner Support
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
    > to the limited number of phone-based technical support incidents. Complex
    > issues or server-down situations are not recommended for the newsgroups.
    > Issues of this nature are best handled working with a Microsoft Support
    > Engineer using one of your phone-based incidents.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    > --------------------
    > | From: "germ" <>
    > | Subject: objectdatasource
    > | Date: Sun, 31 Jan 2010 09:31:00 -0500
    > | Lines: 15
    > | X-Priority: 3
    > | X-MSMail-Priority: Normal
    > | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    > | X-RFC2646: Format=Flowed; Original
    > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    > | Message-ID: <>
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet
    > | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com 206.248.138.28
    > | Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    > | Xref: TK2MSFTNGHUB02.phx.gbl
    > microsoft.public.dotnet.framework.aspnet:96142
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > |
    > | I really like the objectdata source with one notable exception.
    > | When doing an update, a new() object is created and the bound values on
    > the
    > | form used to set its properties with all other properties set to default
    > | values.
    > | I would like to be able to override the object creation step and provide
    > a
    > | copy of the original object to be updated such that all values are set
    > not
    > | just those that were bound on the form.
    > |
    > | As far as I can tell there is no way to do this - am I missing something
    > and
    > | this is possible ?
    > |
    > | Gerry
    > |
    > |
    > |
    > |
    >
    >
     
    germ, Feb 1, 2010
    #3
  4. germ

    germ Guest

    well after my 1st major foray into reflection I have this working as
    desired.
    In the end I derived classes from ObjectDataSource and ObjectDataSourceView,
    there was minor change to the ObjectDataSource constructor and a slightly
    more involved change to the ObjectDataSourceView.ExecuteUpdate() method.
    Luckily these 2 classes have minimal security settings to allow reflected
    access to private members.

    Now the question is - can I globally specifiy that any references to
    System.Web.UI.WebControls.ObjectDataSource should instead use
    Some.Other.ObjectDataSource ?
    I seem to recall seeing this type of thing being done in the web.config in
    the past for previews & betas - I can't find an example but I have the
    feeling this was at the assembly level and I only want to replace a single
    control.

    Gerry




    "germ" <> wrote in message
    news:%...
    > Thanks Thomas,
    >
    > This seems to work fine under the specific ODS configuration given in the
    > example.
    > However, in cases where multiple forms each update a different subset of
    > properties on the same data object, we are forced to setup an update
    > method specific to each form. I would prefer to configure the ODS on each
    > form with the DataObjectTypeName to all invoke the same update method
    > which takes the updated data object as its only argument .
    > In this scenario, you can't modifiy the InputParameters in the Updating
    > event - it generates the runtime error : System.NotSupportedException: The
    > OrderedDictionary is readonly and cannot be modified.
    > But this is moot anyway because the new object has already been created
    > and populated before this point.
    >
    > I am thinking that this will involve a custom ObjectDataSource. I may
    > either try to track down the source for the ODS or use relector to see if
    > deriving from the standard ODS is possible.
    >
    > Gerry
    >
    >
    >
    >
    > "Thomas Sun [MSFT]" <> wrote in message
    > news:...
    >> Hi Gerry,
    >>
    >> From your description, I understand that you want to get the copy of
    >> original data and only change the value needed to be changed while
    >> updating
    >> with ObjactDataSource control, right? If I have misunderstood you, please
    >> feel free to let me know.
    >>
    >> To get original data, you can save it in ViewState in ObjectDataSource's
    >> Selected event and retrieve it in Updating event and then modify it.
    >>
    >> For more information, see
    >>
    >> http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    >> source.updating.aspx
    >> http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    >> 06-cs.aspx
    >>
    >>
    >> I look forward to receiving your test results.
    >>
    >>
    >> --
    >> Best Regards,
    >> Thomas Sun
    >>
    >> Microsoft Online Partner Support
    >>
    >> ==================================================
    >> Get notification to my posts through email? Please refer to
    >> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    >> ications.
    >>
    >> With newsgroups, MSDN subscribers enjoy unlimited, free support as
    >> opposed
    >> to the limited number of phone-based technical support incidents. Complex
    >> issues or server-down situations are not recommended for the newsgroups.
    >> Issues of this nature are best handled working with a Microsoft Support
    >> Engineer using one of your phone-based incidents.
    >> ==================================================
    >>
    >> This posting is provided "AS IS" with no warranties, and confers no
    >> rights.
    >>
    >> --------------------
    >> | From: "germ" <>
    >> | Subject: objectdatasource
    >> | Date: Sun, 31 Jan 2010 09:31:00 -0500
    >> | Lines: 15
    >> | X-Priority: 3
    >> | X-MSMail-Priority: Normal
    >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    >> | X-RFC2646: Format=Flowed; Original
    >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    >> | Message-ID: <>
    >> | Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com 206.248.138.28
    >> | Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    >> | Xref: TK2MSFTNGHUB02.phx.gbl
    >> microsoft.public.dotnet.framework.aspnet:96142
    >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >> |
    >> | I really like the objectdata source with one notable exception.
    >> | When doing an update, a new() object is created and the bound values on
    >> the
    >> | form used to set its properties with all other properties set to
    >> default
    >> | values.
    >> | I would like to be able to override the object creation step and
    >> provide
    >> a
    >> | copy of the original object to be updated such that all values are set
    >> not
    >> | just those that were bound on the form.
    >> |
    >> | As far as I can tell there is no way to do this - am I missing
    >> something
    >> and
    >> | this is possible ?
    >> |
    >> | Gerry
    >> |
    >> |
    >> |
    >> |
    >>
    >>

    >
    >
     
    germ, Feb 1, 2010
    #4
  5. Hi Gerry,

    Thanks for your response. I am glad that you worked it out.

    To globally use your custom ObjectDataSource control, we can register it in
    web.config's Controls section and then use this custom ObjectDataSoure in
    page. For example:
    ======================
    <pages>
    <controls>
    <add assembly="CustomObjectDataSource"
    namespace="CustomObjectDataSource" tagPrefix="cc1"/>
    </controls>
    </pages>
    ======================

    You can also add this custom ObjectDataSource into Toolbox so that you can
    drag and drop it into page like other server control.

    For more information, see
    http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-
    user-controls-and-custom-controls-in-web-config.aspx
    http://msdn.microsoft.com/en-us/library/1e9b4c9f.aspx


    I look forward to receiving your test results.



    Best Regards,
    Thomas Sun

    Microsoft Online Partner Support
    --------------------|
    | well after my 1st major foray into reflection I have this working as
    | desired.
    | In the end I derived classes from ObjectDataSource and
    ObjectDataSourceView,
    | there was minor change to the ObjectDataSource constructor and a slightly
    | more involved change to the ObjectDataSourceView.ExecuteUpdate() method.
    | Luckily these 2 classes have minimal security settings to allow reflected
    | access to private members.
    |
    | Now the question is - can I globally specifiy that any references to
    | System.Web.UI.WebControls.ObjectDataSource should instead use
    | Some.Other.ObjectDataSource ?
    | I seem to recall seeing this type of thing being done in the web.config
    in
    | the past for previews & betas - I can't find an example but I have the
    | feeling this was at the assembly level and I only want to replace a
    single
    | control.
    |
    | Gerry
    |
    |
    |
    |
    | "germ" <> wrote in message
    | news:%...
    | > Thanks Thomas,
    | >
    | > This seems to work fine under the specific ODS configuration given in
    the
    | > example.
    | > However, in cases where multiple forms each update a different subset
    of
    | > properties on the same data object, we are forced to setup an update
    | > method specific to each form. I would prefer to configure the ODS on
    each
    | > form with the DataObjectTypeName to all invoke the same update method
    | > which takes the updated data object as its only argument .
    | > In this scenario, you can't modifiy the InputParameters in the Updating
    | > event - it generates the runtime error : System.NotSupportedException:
    The
    | > OrderedDictionary is readonly and cannot be modified.
    | > But this is moot anyway because the new object has already been created
    | > and populated before this point.
    | >
    | > I am thinking that this will involve a custom ObjectDataSource. I may
    | > either try to track down the source for the ODS or use relector to see
    if
    | > deriving from the standard ODS is possible.
    | >
    | > Gerry
    | >
    | >
    | >
    | >
    | > "Thomas Sun [MSFT]" <> wrote in message
    | > news:...
    | >> Hi Gerry,
    | >>
    | >> From your description, I understand that you want to get the copy of
    | >> original data and only change the value needed to be changed while
    | >> updating
    | >> with ObjactDataSource control, right? If I have misunderstood you,
    please
    | >> feel free to let me know.
    | >>
    | >> To get original data, you can save it in ViewState in
    ObjectDataSource's
    | >> Selected event and retrieve it in Updating event and then modify it.
    | >>
    | >> For more information, see
    | >>
    | >>
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    | >> source.updating.aspx
    | >>
    http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    | >> 06-cs.aspx
    | >>
    | >>
    | >> I look forward to receiving your test results.
    | >>
    | >>
    | >> --
    | >> Best Regards,
    | >> Thomas Sun
    | >>
    | >> Microsoft Online Partner Support
    | >>
    | >> ==================================================
    | >> Get notification to my posts through email? Please refer to
    | >>
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    | >> ications.
    | >>
    | >> With newsgroups, MSDN subscribers enjoy unlimited, free support as
    | >> opposed
    | >> to the limited number of phone-based technical support incidents.
    Complex
    | >> issues or server-down situations are not recommended for the
    newsgroups.
    | >> Issues of this nature are best handled working with a Microsoft Support
    | >> Engineer using one of your phone-based incidents.
    | >> ==================================================
    | >>
    | >> This posting is provided "AS IS" with no warranties, and confers no
    | >> rights.
    | >>
    | >> --------------------
    | >> | From: "germ" <>
    | >> | Subject: objectdatasource
    | >> | Date: Sun, 31 Jan 2010 09:31:00 -0500
    | >> | Lines: 15
    | >> | X-Priority: 3
    | >> | X-MSMail-Priority: Normal
    | >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    | >> | X-RFC2646: Format=Flowed; Original
    | >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    | >> | Message-ID: <>
    | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | >> | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com 206.248.138.28
    | >> | Path:
    TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    | >> | Xref: TK2MSFTNGHUB02.phx.gbl
    | >> microsoft.public.dotnet.framework.aspnet:96142
    | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | >> |
    | >> | I really like the objectdata source with one notable exception.
    | >> | When doing an update, a new() object is created and the bound values
    on
    | >> the
    | >> | form used to set its properties with all other properties set to
    | >> default
    | >> | values.
    | >> | I would like to be able to override the object creation step and
    | >> provide
    | >> a
    | >> | copy of the original object to be updated such that all values are
    set
    | >> not
    | >> | just those that were bound on the form.
    | >> |
    | >> | As far as I can tell there is no way to do this - am I missing
    | >> something
    | >> and
    | >> | this is possible ?
    | >> |
    | >> | Gerry
    | >> |
    | >> |
    | >> |
    | >> |
    | >>
    | >>
    | >
    | >
    |
    |
    |
     
    Thomas Sun [MSFT], Feb 2, 2010
    #5
  6. germ

    germ Guest

    thanks thomas

    I did this same web.config mod and I added a control adapter for the
    ObjectDataSource that will throw an exception at runtime if the control is
    not an isntance of my custom version.

    Gerry





    "Thomas Sun [MSFT]" <> wrote in message
    news:...
    > Hi Gerry,
    >
    > Thanks for your response. I am glad that you worked it out.
    >
    > To globally use your custom ObjectDataSource control, we can register it
    > in
    > web.config's Controls section and then use this custom ObjectDataSoure in
    > page. For example:
    > ======================
    > <pages>
    > <controls>
    > <add assembly="CustomObjectDataSource"
    > namespace="CustomObjectDataSource" tagPrefix="cc1"/>
    > </controls>
    > </pages>
    > ======================
    >
    > You can also add this custom ObjectDataSource into Toolbox so that you can
    > drag and drop it into page like other server control.
    >
    > For more information, see
    > http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-
    > user-controls-and-custom-controls-in-web-config.aspx
    > http://msdn.microsoft.com/en-us/library/1e9b4c9f.aspx
    >
    >
    > I look forward to receiving your test results.
    >
    >
    >
    > Best Regards,
    > Thomas Sun
    >
    > Microsoft Online Partner Support
    > --------------------|
    > | well after my 1st major foray into reflection I have this working as
    > | desired.
    > | In the end I derived classes from ObjectDataSource and
    > ObjectDataSourceView,
    > | there was minor change to the ObjectDataSource constructor and a
    > slightly
    > | more involved change to the ObjectDataSourceView.ExecuteUpdate() method.
    > | Luckily these 2 classes have minimal security settings to allow
    > reflected
    > | access to private members.
    > |
    > | Now the question is - can I globally specifiy that any references to
    > | System.Web.UI.WebControls.ObjectDataSource should instead use
    > | Some.Other.ObjectDataSource ?
    > | I seem to recall seeing this type of thing being done in the web.config
    > in
    > | the past for previews & betas - I can't find an example but I have the
    > | feeling this was at the assembly level and I only want to replace a
    > single
    > | control.
    > |
    > | Gerry
    > |
    > |
    > |
    > |
    > | "germ" <> wrote in message
    > | news:%...
    > | > Thanks Thomas,
    > | >
    > | > This seems to work fine under the specific ODS configuration given in
    > the
    > | > example.
    > | > However, in cases where multiple forms each update a different subset
    > of
    > | > properties on the same data object, we are forced to setup an update
    > | > method specific to each form. I would prefer to configure the ODS on
    > each
    > | > form with the DataObjectTypeName to all invoke the same update method
    > | > which takes the updated data object as its only argument .
    > | > In this scenario, you can't modifiy the InputParameters in the
    > Updating
    > | > event - it generates the runtime error : System.NotSupportedException:
    > The
    > | > OrderedDictionary is readonly and cannot be modified.
    > | > But this is moot anyway because the new object has already been
    > created
    > | > and populated before this point.
    > | >
    > | > I am thinking that this will involve a custom ObjectDataSource. I may
    > | > either try to track down the source for the ODS or use relector to see
    > if
    > | > deriving from the standard ODS is possible.
    > | >
    > | > Gerry
    > | >
    > | >
    > | >
    > | >
    > | > "Thomas Sun [MSFT]" <> wrote in message
    > | > news:...
    > | >> Hi Gerry,
    > | >>
    > | >> From your description, I understand that you want to get the copy of
    > | >> original data and only change the value needed to be changed while
    > | >> updating
    > | >> with ObjactDataSource control, right? If I have misunderstood you,
    > please
    > | >> feel free to let me know.
    > | >>
    > | >> To get original data, you can save it in ViewState in
    > ObjectDataSource's
    > | >> Selected event and retrieve it in Updating event and then modify it.
    > | >>
    > | >> For more information, see
    > | >>
    > | >>
    > http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    > | >> source.updating.aspx
    > | >>
    > http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    > | >> 06-cs.aspx
    > | >>
    > | >>
    > | >> I look forward to receiving your test results.
    > | >>
    > | >>
    > | >> --
    > | >> Best Regards,
    > | >> Thomas Sun
    > | >>
    > | >> Microsoft Online Partner Support
    > | >>
    > | >> ==================================================
    > | >> Get notification to my posts through email? Please refer to
    > | >>
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > | >> ications.
    > | >>
    > | >> With newsgroups, MSDN subscribers enjoy unlimited, free support as
    > | >> opposed
    > | >> to the limited number of phone-based technical support incidents.
    > Complex
    > | >> issues or server-down situations are not recommended for the
    > newsgroups.
    > | >> Issues of this nature are best handled working with a Microsoft
    > Support
    > | >> Engineer using one of your phone-based incidents.
    > | >> ==================================================
    > | >>
    > | >> This posting is provided "AS IS" with no warranties, and confers no
    > | >> rights.
    > | >>
    > | >> --------------------
    > | >> | From: "germ" <>
    > | >> | Subject: objectdatasource
    > | >> | Date: Sun, 31 Jan 2010 09:31:00 -0500
    > | >> | Lines: 15
    > | >> | X-Priority: 3
    > | >> | X-MSMail-Priority: Normal
    > | >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    > | >> | X-RFC2646: Format=Flowed; Original
    > | >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    > | >> | Message-ID: <>
    > | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet
    > | >> | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com 206.248.138.28
    > | >> | Path:
    > TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    > | >> | Xref: TK2MSFTNGHUB02.phx.gbl
    > | >> microsoft.public.dotnet.framework.aspnet:96142
    > | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > | >> |
    > | >> | I really like the objectdata source with one notable exception.
    > | >> | When doing an update, a new() object is created and the bound
    > values
    > on
    > | >> the
    > | >> | form used to set its properties with all other properties set to
    > | >> default
    > | >> | values.
    > | >> | I would like to be able to override the object creation step and
    > | >> provide
    > | >> a
    > | >> | copy of the original object to be updated such that all values are
    > set
    > | >> not
    > | >> | just those that were bound on the form.
    > | >> |
    > | >> | As far as I can tell there is no way to do this - am I missing
    > | >> something
    > | >> and
    > | >> | this is possible ?
    > | >> |
    > | >> | Gerry
    > | >> |
    > | >> |
    > | >> |
    > | >> |
    > | >>
    > | >>
    > | >
    > | >
    > |
    > |
    > |
    >
     
    germ, Feb 2, 2010
    #6
  7. Hi Gerry,

    Where did you get the error message? The error message means that you are
    trying to use an Object which is not set to an instance.

    Since this control is custom ASP.NET server control, please ensure its
    Namespace and Class Name is correct in register syntax in web.config.

    Besides, you can send me an example which can reproduce the issue. My email
    address is

    I look forward to hearing from you.

    --

    Best Regards,
    Thomas Sun

    Microsoft Online Partner Support

    --------------------
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | thanks thomas
    |
    | I did this same web.config mod and I added a control adapter for the
    | ObjectDataSource that will throw an exception at runtime if the control
    is
    | not an isntance of my custom version.
    |
    | Gerry
    |
    |
    |
    |
    |
    | "Thomas Sun [MSFT]" <> wrote in message
    | news:...
    | > Hi Gerry,
    | >
    | > Thanks for your response. I am glad that you worked it out.
    | >
    | > To globally use your custom ObjectDataSource control, we can register
    it
    | > in
    | > web.config's Controls section and then use this custom ObjectDataSoure
    in
    | > page. For example:
    | > ======================
    | > <pages>
    | > <controls>
    | > <add assembly="CustomObjectDataSource"
    | > namespace="CustomObjectDataSource" tagPrefix="cc1"/>
    | > </controls>
    | > </pages>
    | > ======================
    | >
    | > You can also add this custom ObjectDataSource into Toolbox so that you
    can
    | > drag and drop it into page like other server control.
    | >
    | > For more information, see
    | >
    http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-
    | > user-controls-and-custom-controls-in-web-config.aspx
    | > http://msdn.microsoft.com/en-us/library/1e9b4c9f.aspx
    | >
    | >
    | > I look forward to receiving your test results.
    | >
    | >
    | >
    | > Best Regards,
    | > Thomas Sun
    | >
    | > Microsoft Online Partner Support
    | > --------------------|
    | > | well after my 1st major foray into reflection I have this working as
    | > | desired.
    | > | In the end I derived classes from ObjectDataSource and
    | > ObjectDataSourceView,
    | > | there was minor change to the ObjectDataSource constructor and a
    | > slightly
    | > | more involved change to the ObjectDataSourceView.ExecuteUpdate()
    method.
    | > | Luckily these 2 classes have minimal security settings to allow
    | > reflected
    | > | access to private members.
    | > |
    | > | Now the question is - can I globally specifiy that any references to
    | > | System.Web.UI.WebControls.ObjectDataSource should instead use
    | > | Some.Other.ObjectDataSource ?
    | > | I seem to recall seeing this type of thing being done in the
    web.config
    | > in
    | > | the past for previews & betas - I can't find an example but I have the
    | > | feeling this was at the assembly level and I only want to replace a
    | > single
    | > | control.
    | > |
    | > | Gerry
    | > |
    | > |
    | > |
    | > |
    | > | "germ" <> wrote in message
    | > | news:%...
    | > | > Thanks Thomas,
    | > | >
    | > | > This seems to work fine under the specific ODS configuration given
    in
    | > the
    | > | > example.
    | > | > However, in cases where multiple forms each update a different
    subset
    | > of
    | > | > properties on the same data object, we are forced to setup an update
    | > | > method specific to each form. I would prefer to configure the ODS
    on
    | > each
    | > | > form with the DataObjectTypeName to all invoke the same update
    method
    | > | > which takes the updated data object as its only argument .
    | > | > In this scenario, you can't modifiy the InputParameters in the
    | > Updating
    | > | > event - it generates the runtime error :
    System.NotSupportedException:
    | > The
    | > | > OrderedDictionary is readonly and cannot be modified.
    | > | > But this is moot anyway because the new object has already been
    | > created
    | > | > and populated before this point.
    | > | >
    | > | > I am thinking that this will involve a custom ObjectDataSource. I
    may
    | > | > either try to track down the source for the ODS or use relector to
    see
    | > if
    | > | > deriving from the standard ODS is possible.
    | > | >
    | > | > Gerry
    | > | >
    | > | >
    | > | >
    | > | >
    | > | > "Thomas Sun [MSFT]" <> wrote in message
    | > | > news:...
    | > | >> Hi Gerry,
    | > | >>
    | > | >> From your description, I understand that you want to get the copy
    of
    | > | >> original data and only change the value needed to be changed while
    | > | >> updating
    | > | >> with ObjactDataSource control, right? If I have misunderstood you,
    | > please
    | > | >> feel free to let me know.
    | > | >>
    | > | >> To get original data, you can save it in ViewState in
    | > ObjectDataSource's
    | > | >> Selected event and retrieve it in Updating event and then modify
    it.
    | > | >>
    | > | >> For more information, see
    | > | >>
    | > | >>
    | >
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    | > | >> source.updating.aspx
    | > | >>
    | >
    http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    | > | >> 06-cs.aspx
    | > | >>
    | > | >>
    | > | >> I look forward to receiving your test results.
    | > | >>
    | > | >>
    | > | >> --
    | > | >> Best Regards,
    | > | >> Thomas Sun
    | > | >>
    | > | >> Microsoft Online Partner Support
    | > | >>
    | > | >> ==================================================
    | > | >> Get notification to my posts through email? Please refer to
    | > | >>
    | >
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    | > | >> ications.
    | > | >>
    | > | >> With newsgroups, MSDN subscribers enjoy unlimited, free support as
    | > | >> opposed
    | > | >> to the limited number of phone-based technical support incidents.
    | > Complex
    | > | >> issues or server-down situations are not recommended for the
    | > newsgroups.
    | > | >> Issues of this nature are best handled working with a Microsoft
    | > Support
    | > | >> Engineer using one of your phone-based incidents.
    | > | >> ==================================================
    | > | >>
    | > | >> This posting is provided "AS IS" with no warranties, and confers no
    | > | >> rights.
    | > | >>
    | > | >> --------------------
    | > | >> | From: "germ" <>
    | > | >> | Subject: objectdatasource
    | > | >> | Date: Sun, 31 Jan 2010 09:31:00 -0500
    | > | >> | Lines: 15
    | > | >> | X-Priority: 3
    | > | >> | X-MSMail-Priority: Normal
    | > | >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    | > | >> | X-RFC2646: Format=Flowed; Original
    | > | >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    | > | >> | Message-ID: <>
    | > | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | > | >> | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com 206.248.138.28
    | > | >> | Path:
    | > TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    | > | >> | Xref: TK2MSFTNGHUB02.phx.gbl
    | > | >> microsoft.public.dotnet.framework.aspnet:96142
    | > | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | > | >> |
    | > | >> | I really like the objectdata source with one notable exception.
    | > | >> | When doing an update, a new() object is created and the bound
    | > values
    | > on
    | > | >> the
    | > | >> | form used to set its properties with all other properties set to
    | > | >> default
    | > | >> | values.
    | > | >> | I would like to be able to override the object creation step and
    | > | >> provide
    | > | >> a
    | > | >> | copy of the original object to be updated such that all values
    are
    | > set
    | > | >> not
    | > | >> | just those that were bound on the form.
    | > | >> |
    | > | >> | As far as I can tell there is no way to do this - am I missing
    | > | >> something
    | > | >> and
    | > | >> | this is possible ?
    | > | >> |
    | > | >> | Gerry
    | > | >> |
    | > | >> |
    | > | >> |
    | > | >> |
    | > | >>
    | > | >>
    | > | >
    | > | >
    | > |
    | > |
    | > |
    | >
    |
    |
    |
     
    Thomas Sun [MSFT], Feb 3, 2010
    #7
  8. germ

    germ Guest

    i don't.

    What I said was that I created a control adapter for the objectdatasource
    that will throw an exception at runtime if I use the standard ODS somewhere
    on my site rather ths using my custom version.
    The idea here is that I want to ensure that I always use my control as the
    DAL update methods are depending on the enhanced 'fully populated objects'
    ODS functionality.






    "Thomas Sun [MSFT]" <> wrote in message
    news:...
    > Hi Gerry,
    >
    > Where did you get the error message? The error message means that you are
    > trying to use an Object which is not set to an instance.
    >
    > Since this control is custom ASP.NET server control, please ensure its
    > Namespace and Class Name is correct in register syntax in web.config.
    >
    > Besides, you can send me an example which can reproduce the issue. My
    > email
    > address is
    >
    > I look forward to hearing from you.
    >
    > --
    >
    > Best Regards,
    > Thomas Sun
    >
    > Microsoft Online Partner Support
    >
    > --------------------
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > |
    > | thanks thomas
    > |
    > | I did this same web.config mod and I added a control adapter for the
    > | ObjectDataSource that will throw an exception at runtime if the control
    > is
    > | not an isntance of my custom version.
    > |
    > | Gerry
    > |
    > |
    > |
    > |
    > |
    > | "Thomas Sun [MSFT]" <> wrote in message
    > | news:...
    > | > Hi Gerry,
    > | >
    > | > Thanks for your response. I am glad that you worked it out.
    > | >
    > | > To globally use your custom ObjectDataSource control, we can register
    > it
    > | > in
    > | > web.config's Controls section and then use this custom ObjectDataSoure
    > in
    > | > page. For example:
    > | > ======================
    > | > <pages>
    > | > <controls>
    > | > <add assembly="CustomObjectDataSource"
    > | > namespace="CustomObjectDataSource" tagPrefix="cc1"/>
    > | > </controls>
    > | > </pages>
    > | > ======================
    > | >
    > | > You can also add this custom ObjectDataSource into Toolbox so that you
    > can
    > | > drag and drop it into page like other server control.
    > | >
    > | > For more information, see
    > | >
    > http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-
    > | > user-controls-and-custom-controls-in-web-config.aspx
    > | > http://msdn.microsoft.com/en-us/library/1e9b4c9f.aspx
    > | >
    > | >
    > | > I look forward to receiving your test results.
    > | >
    > | >
    > | >
    > | > Best Regards,
    > | > Thomas Sun
    > | >
    > | > Microsoft Online Partner Support
    > | > --------------------|
    > | > | well after my 1st major foray into reflection I have this working as
    > | > | desired.
    > | > | In the end I derived classes from ObjectDataSource and
    > | > ObjectDataSourceView,
    > | > | there was minor change to the ObjectDataSource constructor and a
    > | > slightly
    > | > | more involved change to the ObjectDataSourceView.ExecuteUpdate()
    > method.
    > | > | Luckily these 2 classes have minimal security settings to allow
    > | > reflected
    > | > | access to private members.
    > | > |
    > | > | Now the question is - can I globally specifiy that any references to
    > | > | System.Web.UI.WebControls.ObjectDataSource should instead use
    > | > | Some.Other.ObjectDataSource ?
    > | > | I seem to recall seeing this type of thing being done in the
    > web.config
    > | > in
    > | > | the past for previews & betas - I can't find an example but I have
    > the
    > | > | feeling this was at the assembly level and I only want to replace a
    > | > single
    > | > | control.
    > | > |
    > | > | Gerry
    > | > |
    > | > |
    > | > |
    > | > |
    > | > | "germ" <> wrote in message
    > | > | news:%...
    > | > | > Thanks Thomas,
    > | > | >
    > | > | > This seems to work fine under the specific ODS configuration given
    > in
    > | > the
    > | > | > example.
    > | > | > However, in cases where multiple forms each update a different
    > subset
    > | > of
    > | > | > properties on the same data object, we are forced to setup an
    > update
    > | > | > method specific to each form. I would prefer to configure the ODS
    > on
    > | > each
    > | > | > form with the DataObjectTypeName to all invoke the same update
    > method
    > | > | > which takes the updated data object as its only argument .
    > | > | > In this scenario, you can't modifiy the InputParameters in the
    > | > Updating
    > | > | > event - it generates the runtime error :
    > System.NotSupportedException:
    > | > The
    > | > | > OrderedDictionary is readonly and cannot be modified.
    > | > | > But this is moot anyway because the new object has already been
    > | > created
    > | > | > and populated before this point.
    > | > | >
    > | > | > I am thinking that this will involve a custom ObjectDataSource. I
    > may
    > | > | > either try to track down the source for the ODS or use relector to
    > see
    > | > if
    > | > | > deriving from the standard ODS is possible.
    > | > | >
    > | > | > Gerry
    > | > | >
    > | > | >
    > | > | >
    > | > | >
    > | > | > "Thomas Sun [MSFT]" <> wrote in
    > message
    > | > | > news:...
    > | > | >> Hi Gerry,
    > | > | >>
    > | > | >> From your description, I understand that you want to get the copy
    > of
    > | > | >> original data and only change the value needed to be changed
    > while
    > | > | >> updating
    > | > | >> with ObjactDataSource control, right? If I have misunderstood
    > you,
    > | > please
    > | > | >> feel free to let me know.
    > | > | >>
    > | > | >> To get original data, you can save it in ViewState in
    > | > ObjectDataSource's
    > | > | >> Selected event and retrieve it in Updating event and then modify
    > it.
    > | > | >>
    > | > | >> For more information, see
    > | > | >>
    > | > | >>
    > | >
    > http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdata
    > | > | >> source.updating.aspx
    > | > | >>
    > | >
    > http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/data-access/tutorial-
    > | > | >> 06-cs.aspx
    > | > | >>
    > | > | >>
    > | > | >> I look forward to receiving your test results.
    > | > | >>
    > | > | >>
    > | > | >> --
    > | > | >> Best Regards,
    > | > | >> Thomas Sun
    > | > | >>
    > | > | >> Microsoft Online Partner Support
    > | > | >>
    > | > | >> ==================================================
    > | > | >> Get notification to my posts through email? Please refer to
    > | > | >>
    > | >
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > | > | >> ications.
    > | > | >>
    > | > | >> With newsgroups, MSDN subscribers enjoy unlimited, free support
    > as
    > | > | >> opposed
    > | > | >> to the limited number of phone-based technical support incidents.
    > | > Complex
    > | > | >> issues or server-down situations are not recommended for the
    > | > newsgroups.
    > | > | >> Issues of this nature are best handled working with a Microsoft
    > | > Support
    > | > | >> Engineer using one of your phone-based incidents.
    > | > | >> ==================================================
    > | > | >>
    > | > | >> This posting is provided "AS IS" with no warranties, and confers
    > no
    > | > | >> rights.
    > | > | >>
    > | > | >> --------------------
    > | > | >> | From: "germ" <>
    > | > | >> | Subject: objectdatasource
    > | > | >> | Date: Sun, 31 Jan 2010 09:31:00 -0500
    > | > | >> | Lines: 15
    > | > | >> | X-Priority: 3
    > | > | >> | X-MSMail-Priority: Normal
    > | > | >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
    > | > | >> | X-RFC2646: Format=Flowed; Original
    > | > | >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
    > | > | >> | Message-ID: <>
    > | > | >> | Newsgroups: microsoft.public.dotnet.framework.aspnet
    > | > | >> | NNTP-Posting-Host: 206-248-138-28.dsl.teksavvy.com
    > 206.248.138.28
    > | > | >> | Path:
    > | > TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
    > | > | >> | Xref: TK2MSFTNGHUB02.phx.gbl
    > | > | >> microsoft.public.dotnet.framework.aspnet:96142
    > | > | >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > | > | >> |
    > | > | >> | I really like the objectdata source with one notable exception.
    > | > | >> | When doing an update, a new() object is created and the bound
    > | > values
    > | > on
    > | > | >> the
    > | > | >> | form used to set its properties with all other properties set
    > to
    > | > | >> default
    > | > | >> | values.
    > | > | >> | I would like to be able to override the object creation step
    > and
    > | > | >> provide
    > | > | >> a
    > | > | >> | copy of the original object to be updated such that all values
    > are
    > | > set
    > | > | >> not
    > | > | >> | just those that were bound on the form.
    > | > | >> |
    > | > | >> | As far as I can tell there is no way to do this - am I missing
    > | > | >> something
    > | > | >> and
    > | > | >> | this is possible ?
    > | > | >> |
    > | > | >> | Gerry
    > | > | >> |
    > | > | >> |
    > | > | >> |
    > | > | >> |
    > | > | >>
    > | > | >>
    > | > | >
    > | > | >
    > | > |
    > | > |
    > | > |
    > | >
    > |
    > |
    > |
    >
    >
     
    germ, Feb 3, 2010
    #8
    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. WertmanTheMad

    objectDataSource

    WertmanTheMad, Sep 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    370
    WertmanTheMad
    Sep 15, 2004
  2. WertmanTheMad

    Arrrrg !!!! ObjectDataSource Issues

    WertmanTheMad, Oct 8, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,219
    WertmanTheMad
    Oct 8, 2004
  3. =?Utf-8?B?RG9u?=

    ObjectDataSource

    =?Utf-8?B?RG9u?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    426
    =?Utf-8?B?RG9u?=
    Nov 22, 2004
  4. Microsoft news
    Replies:
    2
    Views:
    9,297
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    258
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page