|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
objectdatasource.update() fires System.InvalidOperationExceptionwe have a strange error message here: I've written a small detail sample page, where I can update one reocrd with an objectdatasource control and the detailsview control. the objectdatasource.confictdetection is set to 'CompareAllValues'. The Updatemethod is UpdateXY and I've set two updateparameters classX and original_callsX. when I use the update link provided by the detailsview control, everything works as expected. The problem comes now: I added a button on the page and labeled it 'Update'. In the clicked event I added the code objectdatasource1.Update(). Here the following exception is fired immediatelly: You have specified that your update method compares all values on ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: You have specified that your update method compares all values on ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. You have specified that your update method compares all values on ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: You have specified that your update method compares all values on ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. Stack Trace: [InvalidOperationException: You have specified that your update method compares all values on ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges.] System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +703 System.Web.UI.WebControls.ObjectDataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues) +37 System.Web.UI.WebControls.ObjectDataSource.Update() +42 CommodityDetail.btnUpdate_Click(Object sender, EventArgs e) in c:\Application\vs2005\Sample2_ObjectDataSource_IEnum\UserInterface\CommodityDetail.aspx.cs:19 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838 Any help? Thanks in advance Markus Hi Markus,
Welcome to ASPNET newsgroup. Regarding on the ObjectDatasource.Update method throw exception problem, based on my understanding, it is because when you manually call the ObjectDataSource.Update method, it hasn't be supplied the required inputParameters. When we use the DetailsView or GridView's "update" button, those parameters will be retrieved from the detailsview or GridView's current edit item.... So for your scenario, we'd suggest you consider the following means to do update(for the current edit row) in our own submit button" 1. Instead of calling ObjectDataSource.Update method, we call DetailsView.UpdateItem method, this method will update the current Item(in edit mode).. And it'll help retreive the required parameters from the DetailsView, just as when we click the "update" button generated by DetailsView..... e.g: protected void btnUpdate_Click(object sender, EventArgs e) { if (DetailsView1.CurrentMode == DetailsViewMode.Edit) { DetailsView1.UpdateItem(true); } } 2. Also, we can use the ObjectDataSource.Update method, however, we need also intercept the event through the ObjectDatasource's "Updating" event, at there we can manually supply all the parameters required or updating. e.g: protected void btnUpdate_Click(object sender, EventArgs e) { if (DetailsView1.CurrentMode == DetailsViewMode.Edit) { ObjectDataSource1.Update(); } } protected void ObjectDataSource1_Updating(object sender, ObjectDataSourceMethodEventArgs e) { Response.Write("<br>Count: " + e.InputParameters.Count); foreach (System.Collections.DictionaryEntry param in e.InputParameters) { Response.Write("<br>" + param.Key + " " + param.Value); } } #I just print out all the required parameters ... You need to assign the correct value in each entry (since they're all empty when we manually call ObjectDataSource.Update....) Hope helps. Thanks, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- Show quoteHide quote | Thread-Topic: objectdatasource.update() fires microsoft.public.dotnet.framework.aspnet.webcontrols:31973System.InvalidOperationException | thread-index: AcYGRsOhr5M0QfvRSXSvHlubW+2H5g== | X-WBNR-Posting-Host: 146.148.72.21 | From: =?Utf-8?B?TWFya3Vz?= <kraft.mpfyl@newsgroups.nospam> | Subject: objectdatasource.update() fires System.InvalidOperationException | Date: Wed, 21 Dec 2005 07:54:02 -0800 | Lines: 72 | Message-ID: <E0F83AE2-7553-49E1-8E96-1E9F1C5ED***@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="Utf-8" | Content-Transfer-Encoding: 7bit | X-Newsreader: Microsoft CDO for Windows 2000 | Content-Class: urn:content-classes:message | Importance: normal | Priority: normal | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0 | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250 | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary | | hello, | we have a strange error message here: | | I've written a small detail sample page, where I can update one reocrd with | an objectdatasource control and the detailsview control. | the objectdatasource.confictdetection is set to 'CompareAllValues'. The | Updatemethod is UpdateXY and I've set two updateparameters classX and | original_callsX. | | when I use the update link provided by the detailsview control, everything | works as expected. | | The problem comes now: | I added a button on the page and labeled it 'Update'. In the clicked event I | added the code objectdatasource1.Update(). | Here the following exception is fired immediatelly: | You have specified that your update method compares all values on | ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues | is empty. Pass in a valid dictionary for update or change your mode to | OverwriteChanges. | Description: An unhandled exception occurred during the execution of the | current web request. Please review the stack trace for more information about | the error and where it originated in the code. | | Exception Details: System.InvalidOperationException: You have specified that | your update method compares all values on ObjectDataSource 'odsCommodity', | but the dictionary passed in for oldValues is empty. Pass in a valid | dictionary for update or change your mode to OverwriteChanges. | | You have specified that your update method compares all values on | ObjectDataSource 'odsCommodity', but the dictionary passed in for oldValues | is empty. Pass in a valid dictionary for update or change your mode to | OverwriteChanges. | Description: An unhandled exception occurred during the execution of the | current web request. Please review the stack trace for more information about | the error and where it originated in the code. | | Exception Details: System.InvalidOperationException: You have specified that | your update method compares all values on ObjectDataSource 'odsCommodity', | but the dictionary passed in for oldValues is empty. Pass in a valid | dictionary for update or change your mode to OverwriteChanges. | | Stack Trace: | | | [InvalidOperationException: You have specified that your update method | compares all values on ObjectDataSource 'odsCommodity', but the dictionary | passed in for oldValues is empty. Pass in a valid dictionary for update or | change your mode to OverwriteChanges.] | | keys, IDictionary values, IDictionary oldValues) +703 c:\Application\vs2005\Sample2_ObjectDataSource_IEnum\UserInterface\Commodity| System.Web.UI.WebControls.ObjectDataSourceView.Update(IDictionary keys, | IDictionary values, IDictionary oldValues) +37 | System.Web.UI.WebControls.ObjectDataSource.Update() +42 | CommodityDetail.btnUpdate_Click(Object sender, EventArgs e) in Detail.aspx.cs:19 | System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo| System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) | +116 | stBackEvent(String eventArgument) +31 Show quoteHide quote | System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler | sourceControl, String eventArgument) +32 | System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72 | System.Web.UI.Page.ProcessRequestMain(Boolean | includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838 | | | Any help? | Thanks in advance | Markus | | Hi Markus,
Any progress on this issue or does my last reply helps a little? If there're anything else we can help, please feel free to post here. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- Show quoteHide quote | X-Tomcat-ID: 104388298 microsoft.public.dotnet.framework.aspnet.webcontrols:32003| References: <E0F83AE2-7553-49E1-8E96-1E9F1C5ED***@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain | Content-Transfer-Encoding: 7bit | From: stch***@online.microsoft.com (Steven Cheng[MSFT]) | Organization: Microsoft | Date: Thu, 22 Dec 2005 06:23:09 GMT | Subject: RE: objectdatasource.update() fires System.InvalidOperationException | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | Message-ID: <NJeO0AsBGHA.***@TK2MSFTNGXA02.phx.gbl> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | Lines: 178 | Path: TK2MSFTNGXA02.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182 c:\Application\vs2005\Sample2_ObjectDataSource_IEnum\UserInterface\Commodity| | Hi Markus, | | Welcome to ASPNET newsgroup. | Regarding on the ObjectDatasource.Update method throw exception problem, | based on my understanding, it is because when you manually call the | ObjectDataSource.Update method, it hasn't be supplied the required | inputParameters. When we use the DetailsView or GridView's "update" button, | those parameters will be retrieved from the detailsview or GridView's | current edit item.... | | So for your scenario, we'd suggest you consider the following means to do | update(for the current edit row) in our own submit button" | | 1. Instead of calling ObjectDataSource.Update method, we call | DetailsView.UpdateItem method, this method will update the current Item(in | edit mode).. And it'll help retreive the required parameters from the | DetailsView, just as when we click the "update" button generated by | DetailsView..... e.g: | | protected void btnUpdate_Click(object sender, EventArgs e) | { | if (DetailsView1.CurrentMode == DetailsViewMode.Edit) | { | DetailsView1.UpdateItem(true); | } | | } | | | 2. Also, we can use the ObjectDataSource.Update method, however, we need | also intercept the event through the ObjectDatasource's "Updating" event, | at there we can manually supply all the parameters required or updating. | e.g: | | | protected void btnUpdate_Click(object sender, EventArgs e) | { | if (DetailsView1.CurrentMode == DetailsViewMode.Edit) | { | ObjectDataSource1.Update(); | } | | } | | | protected void ObjectDataSource1_Updating(object sender, | ObjectDataSourceMethodEventArgs e) | { | Response.Write("<br>Count: " + e.InputParameters.Count); | foreach (System.Collections.DictionaryEntry param in | e.InputParameters) | { | Response.Write("<br>" + param.Key + " " + param.Value); | } | | } | | | #I just print out all the required parameters ... You need to assign the | correct value in each entry (since they're all empty when we manually call | ObjectDataSource.Update....) | | | Hope helps. Thanks, | | Steven Cheng | Microsoft Online Support | | Get Secure! www.microsoft.com/security | (This posting is provided "AS IS", with no warranties, and confers no | rights.) | | | | -------------------- | | Thread-Topic: objectdatasource.update() fires | System.InvalidOperationException | | thread-index: AcYGRsOhr5M0QfvRSXSvHlubW+2H5g== | | X-WBNR-Posting-Host: 146.148.72.21 | | From: =?Utf-8?B?TWFya3Vz?= <kraft.mpfyl@newsgroups.nospam> | | Subject: objectdatasource.update() fires System.InvalidOperationException | | Date: Wed, 21 Dec 2005 07:54:02 -0800 | | Lines: 72 | | Message-ID: <E0F83AE2-7553-49E1-8E96-1E9F1C5ED***@microsoft.com> | | MIME-Version: 1.0 | | Content-Type: text/plain; | | charset="Utf-8" | | Content-Transfer-Encoding: 7bit | | X-Newsreader: Microsoft CDO for Windows 2000 | | Content-Class: urn:content-classes:message | | Importance: normal | | Priority: normal | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0 | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols | | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250 | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl | | Xref: TK2MSFTNGXA02.phx.gbl | microsoft.public.dotnet.framework.aspnet.webcontrols:31973 | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols | | | | hello, | | we have a strange error message here: | | | | I've written a small detail sample page, where I can update one reocrd | with | | an objectdatasource control and the detailsview control. | | the objectdatasource.confictdetection is set to 'CompareAllValues'. The | | Updatemethod is UpdateXY and I've set two updateparameters classX and | | original_callsX. | | | | when I use the update link provided by the detailsview control, | everything | | works as expected. | | | | The problem comes now: | | I added a button on the page and labeled it 'Update'. In the clicked | event I | | added the code objectdatasource1.Update(). | | Here the following exception is fired immediatelly: | | You have specified that your update method compares all values on | | ObjectDataSource 'odsCommodity', but the dictionary passed in for | oldValues | | is empty. Pass in a valid dictionary for update or change your mode to | | OverwriteChanges. | | Description: An unhandled exception occurred during the execution of the | | current web request. Please review the stack trace for more information | about | | the error and where it originated in the code. | | | | Exception Details: System.InvalidOperationException: You have specified | that | | your update method compares all values on ObjectDataSource | 'odsCommodity', | | but the dictionary passed in for oldValues is empty. Pass in a valid | | dictionary for update or change your mode to OverwriteChanges. | | | | You have specified that your update method compares all values on | | ObjectDataSource 'odsCommodity', but the dictionary passed in for | oldValues | | is empty. Pass in a valid dictionary for update or change your mode to | | OverwriteChanges. | | Description: An unhandled exception occurred during the execution of the | | current web request. Please review the stack trace for more information | about | | the error and where it originated in the code. | | | | Exception Details: System.InvalidOperationException: You have specified | that | | your update method compares all values on ObjectDataSource | 'odsCommodity', | | but the dictionary passed in for oldValues is empty. Pass in a valid | | dictionary for update or change your mode to OverwriteChanges. | | | | Stack Trace: | | | | | | [InvalidOperationException: You have specified that your update method | | compares all values on ObjectDataSource 'odsCommodity', but the | dictionary | | passed in for oldValues is empty. Pass in a valid dictionary for update | or | | change your mode to OverwriteChanges.] | | | System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary | | keys, IDictionary values, IDictionary oldValues) +703 | | System.Web.UI.WebControls.ObjectDataSourceView.Update(IDictionary | keys, | | IDictionary values, IDictionary oldValues) +37 | | System.Web.UI.WebControls.ObjectDataSource.Update() +42 | | CommodityDetail.btnUpdate_Click(Object sender, EventArgs e) in | | Detail.aspx.cs:19 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo| | System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96 | | System.Web.UI.WebControls.Button.RaisePostBackEvent(String | eventArgument) | | +116 | | | Show quoteHide quote | stBackEvent(String eventArgument) +31 | | System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler | | sourceControl, String eventArgument) +32 | | System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72 | | System.Web.UI.Page.ProcessRequestMain(Boolean | | includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838 | | | | | | Any help? | | Thanks in advance | | Markus | | | | | |
DropDownList not giving the selected item when a Button is clicked... please help newbie...
Button Click event not firing GridView Multi Select ? Viewing Composite Controls at Design Time Hide SideBar of Wizard Control Custom type converter How to filter file types when using the HTMLInputFile control... Table - no ViewState Better tool for selection - Datagrid or DataList? Required field validator |
|||||||||||||||||||||||