ObjectDataSource UpdateMethod question

J

Jeronimo Bertran

I have a FormView that shows details of a specific record on a table. The
SelecMethod returns a DataSet that includes all the fields from my Event
table and other read-only fields from linked tables. My FormView has
controls that are bound to the fiuelds on the dataset table. I am now
changing the FormView's Default Mode to Edit but I am having problems with
the related fields.

My ObjectDataSource is defined as:

<asp:ObjectDataSource ID="ObjectDataSourceEventDetails"
runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="SelectEventDetails" TypeName="EventData"
DataObjectTypeName="System.Data.DataSet" UpdateMethod="UpdateEventDetails">
<SelectParameters>
<asp:ControlParameter ControlID="GridViewEvents"
Name="eventID" PropertyName="SelectedValue"
Type="Int64" />
</SelectParameters>
</asp:ObjectDataSource>


The EventData.SelecEventDetails performs a join with related tables and
returns a single table in a dataset with both the Event fields and the
related fields.

The EventData.UpdateEventDetails funcion takes as parameters the
original_EventID and only the editable fields that belong to the Event
table.

public void UpdateEventDetails(long original_EventID, byte SendState,
string EntryNotes)


I added a button to save changes and when the button is pressed I called:
FormView1.UpdateItem(true);


When UpdateItem is called I receive the following exception:

Could not find a property named 'ImageIndex' on the type specified by the
DataObjectTypeName property in ObjectDataSource
'ObjectDataSourceEventDetails'.

ImageIndex is a field found on a related table which is not updated by
UpdateEventDetails.

I am not sure if I should limit the SelectMethod to return the table and
do the databinding for the read only fields a different way.

Thanks

Jeronimo Bertran
 
W

Walter Wang [MSFT]

Hi Jeronimo,

Thank you for your post!

ObjectDataSource.DataObjectTypeName is used to get or set the name of a
class that the ObjectDataSource control uses for a parameter in an update,
insert, or delete data operation, instead of passing individual values from
the data-bound control.

Since your UpdateMethod of ObjectDataSource is passing individual values,
you should remove 'DataObjectTypeName="System.Data.DataSet"' part from your
ObjectDataSource declaration.

For more information, see MSDN documentation on this property:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
asource.dataobjecttypename(d=ide).aspx

Hope this helps. If anything is unclear, please feel free to post here.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Walter Wang [MSFT]

You are welcome.

Have a nice day!

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

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,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top