ObjectDataSource method parameters

Discussion in 'ASP .Net' started by J055, Nov 8, 2007.

  1. J055

    J055 Guest

    Hi

    I've got an update business object method which takes about 80 parameters.
    I'm getting the 'could not find a non-generic method' error. I know that the
    ObjectDataSource UpdateParameters matches the business object method
    signiture. I ran the code below to discover that the InputParameters is in
    fact a list of bound values in my FormView control, i.e. not the
    UpdateParameters list.

    protected void ObjectDataSource_Updating(object sender,
    ObjectDataSourceMethodEventArgs e)
    {
    foreach (DictionaryEntry var in e.InputParameters)
    {
    Response.Write(var.Key.ToString() + "\n");
    }
    }

    What is the purpose of the UpdateParameters if they don't get used? What am
    I doing wrong or what do I need to understand about the ObjectDataSource
    when using in this context?

    Many thanks
    Andrew
    J055, Nov 8, 2007
    #1
    1. Advertising

  2. Hi Andrew,

    From your description, you're encountering 'could not find a non-generic
    method' error when try performing update through ObjectDataSource control,
    correct?

    As for ObjectDataSource control, though the updateparameters setting will
    determine the parameters for update method(and let the runtime identitfy
    which method of the object should we use for update), however, the actual
    input parameters will depend on the datafields in the databound
    control(Gridview, detailsView ....). And for those fields read in select
    method(as boundfields), they'll also become a autogenerated parameter in
    update method(as old value). For some other behavior, you can refer to the
    following msdn doc:

    #Using Parameters with the ObjectDataSource Control
    http://msdn2.microsoft.com/en-us/library/57hkzhy5.aspx

    Also, I suggest you try setting a custom original_parameter string for
    ObjectDataSource so that original value will appear in InputParameters
    collection as a different naming format:

    #ObjectDataSource.OldValuesParameterFormatString Property
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
    asource.oldvaluesparameterformatstring.aspx

    In addition, if your Object's update method contains large number of
    properties, you may consider use Class objecct rather than parameter lists
    as update method parameter:

    #ObjectDataSource.DataObjectTypeName Property
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
    asource.dataobjecttypename.aspx

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

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



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================


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





    --------------------
    >From: "J055" <>
    >Subject: ObjectDataSource method parameters
    >Date: Thu, 8 Nov 2007 23:50:03 -0000


    >Hi
    >
    >I've got an update business object method which takes about 80 parameters.
    >I'm getting the 'could not find a non-generic method' error. I know that

    the
    >ObjectDataSource UpdateParameters matches the business object method
    >signiture. I ran the code below to discover that the InputParameters is in
    >fact a list of bound values in my FormView control, i.e. not the
    >UpdateParameters list.
    >
    >protected void ObjectDataSource_Updating(object sender,
    >ObjectDataSourceMethodEventArgs e)
    >{
    > foreach (DictionaryEntry var in e.InputParameters)
    > {
    > Response.Write(var.Key.ToString() + "\n");
    > }
    >}
    >
    >What is the purpose of the UpdateParameters if they don't get used? What

    am
    >I doing wrong or what do I need to understand about the ObjectDataSource
    >when using in this context?
    >
    >Many thanks
    >Andrew
    >
    >
    >
    Steven Cheng[MSFT], Nov 9, 2007
    #2
    1. Advertising

  3. J055

    J055 Guest

    Hi Steven

    I've created an object to use instead of the parameters collection. This is
    working much better. I came across the bug which incorrectly formats en-gb
    dates as en-us dates. I've managed to add some code to explicitly convert
    the strings to dates in the FormView Updating event before the
    ObjectDataSourceView calls it's ConvertType method.

    I have another question if you don't mind. I have got the form for the
    FormView edit template working. As it has a large number of controls I'd
    like to share this with the Insert template. The forms essentially contain
    the same controls, with a couple of omissions in the Insert mode). It would
    make sense to me if I could create a UserControl and then use it in both the
    FormView templates. Is this a good idea? I haven't seen any examples. I'm
    wondering how much work is required to make sure I can call the necessary
    ObjectDataSource and FormView events/methods for example. Do you have any
    examples or perhaps you could give me your opinion or any suggestions?

    Thanks again
    Andrew




    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Andrew,
    >
    > From your description, you're encountering 'could not find a non-generic
    > method' error when try performing update through ObjectDataSource control,
    > correct?
    >
    > As for ObjectDataSource control, though the updateparameters setting will
    > determine the parameters for update method(and let the runtime identitfy
    > which method of the object should we use for update), however, the actual
    > input parameters will depend on the datafields in the databound
    > control(Gridview, detailsView ....). And for those fields read in select
    > method(as boundfields), they'll also become a autogenerated parameter in
    > update method(as old value). For some other behavior, you can refer to the
    > following msdn doc:
    >
    > #Using Parameters with the ObjectDataSource Control
    > http://msdn2.microsoft.com/en-us/library/57hkzhy5.aspx
    >
    > Also, I suggest you try setting a custom original_parameter string for
    > ObjectDataSource so that original value will appear in InputParameters
    > collection as a different naming format:
    >
    > #ObjectDataSource.OldValuesParameterFormatString Property
    > http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
    > asource.oldvaluesparameterformatstring.aspx
    >
    > In addition, if your Object's update method contains large number of
    > properties, you may consider use Class objecct rather than parameter lists
    > as update method parameter:
    >
    > #ObjectDataSource.DataObjectTypeName Property
    > http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
    > asource.dataobjecttypename.aspx
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    >
    > ==================================================
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    >
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    >
    > ==================================================
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
    >
    >
    >
    > --------------------
    >>From: "J055" <>
    >>Subject: ObjectDataSource method parameters
    >>Date: Thu, 8 Nov 2007 23:50:03 -0000

    >
    >>Hi
    >>
    >>I've got an update business object method which takes about 80 parameters.
    >>I'm getting the 'could not find a non-generic method' error. I know that

    > the
    >>ObjectDataSource UpdateParameters matches the business object method
    >>signiture. I ran the code below to discover that the InputParameters is in
    >>fact a list of bound values in my FormView control, i.e. not the
    >>UpdateParameters list.
    >>
    >>protected void ObjectDataSource_Updating(object sender,
    >>ObjectDataSourceMethodEventArgs e)
    >>{
    >> foreach (DictionaryEntry var in e.InputParameters)
    >> {
    >> Response.Write(var.Key.ToString() + "\n");
    >> }
    >>}
    >>
    >>What is the purpose of the UpdateParameters if they don't get used? What

    > am
    >>I doing wrong or what do I need to understand about the ObjectDataSource
    >>when using in this context?
    >>
    >>Many thanks
    >>Andrew
    >>
    >>
    >>

    >
    J055, Nov 13, 2007
    #3
  4. Hi Andrew,

    The new question you mentioned is a good idea. I haven't ever tried it(use
    usercontrol as a shared template). However, I do know that you can define a
    separate template file (which contains the ascx like markup in it) and
    other DataBound control (which use template column) can dynanically
    construct the template column by loading the template content from that
    separate template file. Here are some articles introducing ASP.NET template
    and how to can deal with it(dynamically load it):

    #Loading ASP.NET Templates Dynamically
    http://www.dotnetheaven.com/UploadFile/mahesh/DynamicTemplate05112005005542A
    M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930

    #Differences in ASP.NET¡¯s LoadControl vs. LoadTemplate
    http://aspalliance.com/399

    #Understanding Templates in ASP.NET
    http://msdn.microsoft.com/msdnmag/issues/02/01/cutting/

    Hope this also helps.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


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







    --------------------
    >From: "J055" <>
    >References: <>

    <>
    >Subject: Re: ObjectDataSource method parameters
    >Date: Tue, 13 Nov 2007 18:34:59 -0000
    >
    >Hi Steven
    >
    >I've created an object to use instead of the parameters collection. This

    is
    >working much better. I came across the bug which incorrectly formats en-gb
    >dates as en-us dates. I've managed to add some code to explicitly convert
    >the strings to dates in the FormView Updating event before the
    >ObjectDataSourceView calls it's ConvertType method.
    >
    >I have another question if you don't mind. I have got the form for the
    >FormView edit template working. As it has a large number of controls I'd
    >like to share this with the Insert template. The forms essentially contain
    >the same controls, with a couple of omissions in the Insert mode). It

    would
    >make sense to me if I could create a UserControl and then use it in both

    the
    >FormView templates. Is this a good idea? I haven't seen any examples. I'm
    >wondering how much work is required to make sure I can call the necessary
    >ObjectDataSource and FormView events/methods for example. Do you have any
    >examples or perhaps you could give me your opinion or any suggestions?
    >
    >Thanks again
    >Andrew
    >
    >
    >
    Steven Cheng[MSFT], Nov 14, 2007
    #4
  5. J055

    J055 Guest

    Hi Steven

    Thanks for the articles about template controls. I've managed to get a
    FormView to load templates dynamically. However it appears loading controls
    this way is not compatable with 2 way databinding. Do you know if this is
    possible without a lot of work?

    Many thanks
    Andrew


    "Steven Cheng[MSFT]" <> wrote in message
    news:UOd%...
    > Hi Andrew,
    >
    > The new question you mentioned is a good idea. I haven't ever tried it(use
    > usercontrol as a shared template). However, I do know that you can define
    > a
    > separate template file (which contains the ascx like markup in it) and
    > other DataBound control (which use template column) can dynanically
    > construct the template column by loading the template content from that
    > separate template file. Here are some articles introducing ASP.NET
    > template
    > and how to can deal with it(dynamically load it):
    >
    > #Loading ASP.NET Templates Dynamically
    > http://www.dotnetheaven.com/UploadFile/mahesh/DynamicTemplate05112005005542A
    > M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930
    >
    > #Differences in ASP.NET¡¯s LoadControl vs. LoadTemplate
    > http://aspalliance.com/399
    >
    > #Understanding Templates in ASP.NET
    > http://msdn.microsoft.com/msdnmag/issues/02/01/cutting/
    >
    > Hope this also helps.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
    >
    >
    >
    >
    >
    > --------------------
    >>From: "J055" <>
    >>References: <>

    > <>
    >>Subject: Re: ObjectDataSource method parameters
    >>Date: Tue, 13 Nov 2007 18:34:59 -0000
    >>
    >>Hi Steven
    >>
    >>I've created an object to use instead of the parameters collection. This

    > is
    >>working much better. I came across the bug which incorrectly formats en-gb
    >>dates as en-us dates. I've managed to add some code to explicitly convert
    >>the strings to dates in the FormView Updating event before the
    >>ObjectDataSourceView calls it's ConvertType method.
    >>
    >>I have another question if you don't mind. I have got the form for the
    >>FormView edit template working. As it has a large number of controls I'd
    >>like to share this with the Insert template. The forms essentially contain
    >>the same controls, with a couple of omissions in the Insert mode). It

    > would
    >>make sense to me if I could create a UserControl and then use it in both

    > the
    >>FormView templates. Is this a good idea? I haven't seen any examples. I'm
    >>wondering how much work is required to make sure I can call the necessary
    >>ObjectDataSource and FormView events/methods for example. Do you have any
    >>examples or perhaps you could give me your opinion or any suggestions?
    >>
    >>Thanks again
    >>Andrew
    >>
    >>
    >>

    >
    J055, Nov 18, 2007
    #5
  6. J055

    J055 Guest

    Hi

    Just wondered if this thread was still open and if there is any answer to
    the question about using a separate template file in a FormView control with
    2 way binding. Please see previous posts.

    Thanks
    Andrew
    J055, Dec 11, 2007
    #6
  7. Hi Andrew,

    Glad to hear from you. For the previous thread, due to some tool problem, I
    haven't seen your last reply and I've manually query the web interface and
    see it. So the new problem you meet is that you cannot get two-way
    databinding work with dynamically loaded FormView template right?

    I have also performed some test on my side and did found the problem
    behavior you mentioend. It seems the "Bind" based two-way databinding will
    not work(the update parameters are not automatically populated) when the
    template is dynamically loaded from an separate file. Currently I'll do
    some further research on this to see whether this is expected behavior or
    not.

    I'll update you as soon as I get any new information.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


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


    --------------------
    >From: "J055" <>
    >References: <>

    <>
    <Ojp#>
    <UOd#>
    <>
    >Subject: Re: ObjectDataSource method parameters
    >Date: Tue, 11 Dec 2007 14:32:15 -0000


    >Hi
    >
    >Just wondered if this thread was still open and if there is any answer to
    >the question about using a separate template file in a FormView control

    with
    >2 way binding. Please see previous posts.
    >
    >Thanks
    >Andrew
    >
    >
    >
    Steven Cheng[MSFT], Dec 12, 2007
    #7
  8. Hi Andrew,

    Here is something I've found. This issue does have been recorded since some
    other members ever reported it previously. Here is a public web link to the
    issue:

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedba
    ckID=104085

    also, due to some design limitation, it is still unfixed in the latest .net
    framework. However, the issue link does provide a workaround, you can visit
    the following link to get the idea:

    #Dynamically loading an IBindableTemplate
    http://www.developerfusion.co.uk/show/4721/

    Hope this helps some.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


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

    --------------------
    >From: (Steven Cheng[MSFT])
    >Organization: Microsoft
    >Date: Wed, 12 Dec 2007 03:51:40 GMT
    >Subject: Re: ObjectDataSource method parameters


    >
    >Hi Andrew,
    >
    >Glad to hear from you. For the previous thread, due to some tool problem,

    I
    >haven't seen your last reply and I've manually query the web interface and
    >see it. So the new problem you meet is that you cannot get two-way
    >databinding work with dynamically loaded FormView template right?
    >
    >I have also performed some test on my side and did found the problem
    >behavior you mentioend. It seems the "Bind" based two-way databinding will
    >not work(the update parameters are not automatically populated) when the
    >template is dynamically loaded from an separate file. Currently I'll do
    >some further research on this to see whether this is expected behavior or
    >not.
    >
    >I'll update you as soon as I get any new information.
    >
    >Sincerely,
    >
    >Steven Cheng
    >
    >Microsoft MSDN Online Support Lead
    >
    >
    >This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >--------------------
    >>From: "J055" <>
    >>References: <>

    ><>
    ><Ojp#>
    ><UOd#>
    ><>
    >>Subject: Re: ObjectDataSource method parameters
    >>Date: Tue, 11 Dec 2007 14:32:15 -0000

    >
    >>Hi
    >>
    >>Just wondered if this thread was still open and if there is any answer to
    >>the question about using a separate template file in a FormView control

    >with
    >>2 way binding. Please see previous posts.
    >>
    >>Thanks
    >>Andrew
    >>
    >>
    >>

    >
    >
    Steven Cheng[MSFT], Dec 12, 2007
    #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. Replies:
    1
    Views:
    515
    S. Justin Gengo [MCP]
    Feb 4, 2006
  2. =?Utf-8?B?RGFiYmxlcg==?=

    ObjectDataSource Parameters

    =?Utf-8?B?RGFiYmxlcg==?=, Apr 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    751
    =?Utf-8?B?RGFiYmxlcg==?=
    Apr 6, 2006
  3. Dennis
    Replies:
    0
    Views:
    1,144
    Dennis
    Jul 1, 2006
  4. Tina
    Replies:
    1
    Views:
    398
    bruce barker
    Jan 19, 2007
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

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

Share This Page