ASPxGridView提示不支持所指定的方法的解决方法
来源:互联网 发布:金融行业的网络推广 编辑:程序博客网 时间:2024/06/06 08:27
.net是目前非常热门的一种程序编译语言,在.net培训中的众多知识点中,提示不支持所指定的方法的解决方法是非常重要的一个。下面就由达内的老师为大家介绍一下这方面的内容。
今天在使用AspxGridView自定义的update按钮事件的时候,总是报出"不支持所指定的方法"的错误,英文错误是"Specified method is not supported"。因为以前都没有用过AspxGridView自带的update,delete,addnew等方法,所以该问题一直都没有发现。
使用场景是这样的,使用AspxGridView自带的编辑数据功能,点击一个自定义按钮调用StartEdit()方法或AspxGridView自带的Edit按钮,出来了数据编辑窗口,编辑完数据后点击Update,就报出了不"支持所指定的方法"的错误
穿插一下,如果想要把按钮名"update","cancel"改成中文的,可以做如下设置:
<SettingsText CommandCancel="取消" CommandUpdate="确定" />
继续回来,找了以前一个使用DataSourceID绑定AspxGridView的示例来看,发现在用DataSourceID绑定AspxGridView的时候,定义了DeleteMethod,InsertMethod,UpdateMethod三个方法,那我们使用自定义的方法是不是也必须同时定义这三个方法呢,经测试后确实如此。
代码如下:
grid.RowUpdating += new DevExpress.Web.Data.ASPxDataUpdatingEventHandler(grid_RowUpdating);
grid.RowInserting += new DevExpress.Web.Data.ASPxDataInsertingEventHandler(grid_RowInserting);
grid.RowDeleting += new DevExpress.Web.Data.ASPxDataDeletingEventHandler(grid_RowDeleting);
也可以在前台定义:
<dxwgv:AspxGridView ID="grid" runat="server" KeyFieldName="ID" OnRowDeleting="grid_RowDeleting" OnRowInserting="grid_RowInserting" OnRowUpdating="grid_RowUpdating">
grid_RowUpdating,grid_RowInserting,grid_RowDeleting三个方法如下:
void Grid_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
{
e.Cancel = true;
}
void Grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
{
e.Cancel = true;
}
void Grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
BLL.Target bll = new SDIR.BLL.Target();
decimal t_value = 0;
string t_type = "months";
switch (ReportType)
{
case ReportType.Months:
{
t_type = "months";
break;
}
}
for (int i = 0; i < DateCol_List.Count; i++)
{
if (decimal.TryParse(e.NewValues[DateCol_List[i]].ToString(), out t_value))
{
bll.Update(FormID, Convert.ToDateTime(DateCol_List[i]), t_value, t_type);
}
}
e.Cancel = true;
(sender as AspxGridView).CancelEdit();
if (base.Events[_o_grid_updateed] != null)
{
EventHandler grid_updateed = base.Events[_o_grid_updateed] as EventHandler;
grid_updateed(sender, EventArgs.Empty);
}
}
上面Grid_RowUpdating方法中的代码不用理会,是我自己的调试代码,但需要注意的是,在三个方法中,代码e.Cancel = true一定不能少,如果没有这句代码,还是会报"不支持所指定的方法"的错误。
总结,AspxGridView出现"不支持所指定的方法"的错误时,大家应该确认以下四点。
1、AspxGridView已设置了主键,即KeyFieldName属性
2、AspxGridView已定义了事件 OnRowDeleting, OnRowInserting, OnRowUpdating
3、后台有对 OnRowDeleting, OnRowInserting, OnRowUpdating 事件的处理
4、OnRowDeleting, OnRowInserting, OnRowUpdating方法中都包含e.Cancel = true代码。
关于提示不支持所指定的方法的解决方法的内容已经由达内培训的讲师为您介绍完了,希望本文的内容能够对学员们有所帮助。
- ASPxGridView提示不支持所指定的方法的解决方法
- ASPxGridView修改,删除,增加提示“不支持所指定的方法”的原因
- IDataReader.GetChar不支持所指定的方法
- SqlDataReader的GetChar不支持所指定的方法
- mysql删除地址栏所指定的id
- excel导入SQL时提示"数据对于所指定的缓冲区来讲太大"
- 将Excel导入MSSQL2000时出现"对于所指定的缓冲区来讲太大"错误的解决方法?
- 将Excel导入MSSQL2000时出现"对于所指定的缓冲区来讲太大"错误的解决方法
- aspxgridview CustomButtonCallback 不支持弹出消息提示
- aspxgridview CustomButtonCallback 不支持弹出消息提示
- 编译android系统提示不支持64位系统的解决方法
- 编译android系统提示不支持64位系统的解决方法
- ASPxGridView删除、添加、修改成功后,弹出提示对话框的方法
- aspxgridview 单击行的事件实现方法
- ie不支持数组的indexOf()方法的解决方法
- 附加数据库出现"所指定的文件不是有效的SQL Server数据库文件"
- 网络编程之:检查URL所指定的图片是否存在(转)
- 判断所指定的文件或目录(文件夹)是否存在存储过程
- 50个jQuery代码段帮你成为更好的JavaScript开发者
- iOS蓝牙教程
- httpclient 使用
- 女汉子
- 动态规划总结
- ASPxGridView提示不支持所指定的方法的解决方法
- 12. Applet小程序 java
- javaEE servlet jsp 验证码
- 【LeetCode】Wildcard Matching && Regular Expression Matching
- 安卓四大组件之--广播接受者
- 多继承sizeof的求解
- android 地图开发
- shell学习3:文本处理工具
- 好-纹理和材质区别总结