ObjectDataSource '_DataSource' could not find a non-generic method 'Update'

 前提:

AspxGridView + ObjectDataSource + ADO.Net EntityFramework

 实现功能:

 表格内编辑数据

 触发表格更新事件报错:

完整错误信息如下

ObjectDataSource '_DataSource' could not find a non-generic method 'Update' that has parameters: item, original_item, original_Id.

 原因:

由于此次需求没有新增数据功能,只有修改现有数据的功能,所以Datasource对应的操作类中没有Insert方法,只为数据源设置了SelectMethod 与 UpdateMethod,

这样就造成,数据源没有DataObjectTypeName信息

如下:

<asp:ObjectDataSource ID="_WeekClassTimeDataSource" runat="server" ConflictDetection="CompareAllValues"
                OldValuesParameterFormatString="original_{0}" SelectMethod="GetAll" 
                TypeName="XXX.XXX.TestRepository" 
                UpdateMethod="Update">
</asp:ObjectDataSource>

当数据源执行更新方法的时候,从而把更新方法认为是面向参数的更新方法,而不是对象参数的更新方法,从而报错

 解决方式:

手动添加DataObjectTypeName信息 修改后如下:

<asp:ObjectDataSource ID="_WeekClassTimeDataSource" runat="server" ConflictDetection="CompareAllValues"
                OldValuesParameterFormatString="original_{0}" SelectMethod="GetAll" 
                TypeName="XXX.XXX.TestRepository" 
                UpdateMethod="Update" DataObjectTypeName="XXX.XXX.Test">
</asp:ObjectDataSource>


 

阅读更多
换一批

Could not find a method sys_setting(View)

04-28

我用的android studio做项目的,别人用的ELIPSE 今天在XML中定义了一个点击事件sys_setting,然后在JAVA中实现却出现找不到方法,怎么回事?rnXMLrnrn rn rn rn Java中rn public class DevListActivity extends FragmentActivity rn public static Context context;rn protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_dev_list);rn rn public void sys_setting(View view)rn Intent intent = new Intent(context, SysSettingActivity.class);rn startActivity(intent);rn rn rn错误rnjava.lang.IllegalStateException: Could not find a method sys_setting(View) in the activity class com.xfengche.wwww.xfegncheradio_net.DevListActivity for onClick handler on view class android.widget.LinearLayoutrn at android.view.View$1.onClick(View.java:3712)rn at android.view.View.performClick(View.java:4262)rn at android.view.View$PerformClick.run(View.java:17351)rn at android.os.Handler.handleCallback(Handler.java:615)rn at android.os.Handler.dispatchMessage(Handler.java:92)rn at android.os.Looper.loop(Looper.java:137)rn at android.app.ActivityThread.main(ActivityThread.java:4935)rn at java.lang.reflect.Method.invokeNative(Native Method)rn at java.lang.reflect.Method.invoke(Method.java:511)rn at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)rn at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)rn at dalvik.system.NativeStart.main(Native Method)rn Caused by: java.lang.NoSuchMethodException: sys_setting [class android.view.View]rn at java.lang.Class.getConstructorOrMethod(Class.java:460)rn at java.lang.Class.getMethod(Class.java:915)rn at android.view.View$1.onClick(View.java:3705)rn            at android.view.View.performClick(View.java:4262)rn            at android.view.View$PerformClick.run(View.java:17351)rn            at android.os.Handler.handleCallback(Handler.java:615)rn            at android.os.Handler.dispatchMessage(Handler.java:92)rn            at android.os.Looper.loop(Looper.java:137)rn            at android.app.ActivityThread.main(ActivityThread.java:4935)rn            at java.lang.reflect.Method.invokeNative(Native Method)rn            at java.lang.reflect.Method.invoke(Method.java:511)rn            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)rn            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)rn            at dalvik.system.NativeStart.main(Native Method)rn

没有更多推荐了,返回首页