ObjectDataSource method parameters

J

J055

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
 
S

Steven Cheng[MSFT]

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.





--------------------
 
J

J055

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
 
S

Steven Cheng[MSFT]

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.







--------------------
 
J

J055

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
 
J

J055

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
 
S

Steven Cheng[MSFT]

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.


--------------------
<[email protected]>
<Ojp#[email protected]>
 
S

Steven Cheng[MSFT]

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: (e-mail address removed) (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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top