.NET Performance Blog

April 28, 2006

ObjectDataSource: UpdateParameters ignored if DataObjectTypeName is used

Filed under: .NET,Bug Fix — Eric P @ 2:28 pm

If you specify 'DataObjectTypeName' parameter in ObjectDataSource — UpdateParameters get ignored. So if you have:

<asp:ObjectDataSource ID="objectDataSource" runat="server"

DataObjectTypeName="Customer" InsertMethod="Save"
UpdateMethod="Save"
DeleteMethod="Delete"
SelectMethod="LoadList"
TypeName="CustomerLogic">

<UpdateParameters>

<asp:Parameter Name="CategoryID" DefaultValue="5"/>

</UpdateParameters>

</asp:ObjectDataSource>

When you do update — parameter 'CategoryID' is not bind to Customer.CategoryID.

The solution to this problem is to add parameters dynamically in Updating event handler:

protected void objectDataSource_Updating(object sender, ObjectDataSourceMethodEventArgs e)

{

Customer customer=(Customer)e.InputParameters[0];

customer.CategoryID=5;

}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: