GridView的UpdateMethod不点火 [英] GridView's UpdateMethod not firing

查看:211
本文介绍了GridView的UpdateMethod不点火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我绑定到ObjectDataSource控件编程,像一个GridView:

I've got a GridView that I bind to a ObjectDataSource programmatically, like:

ObjectDataSource risks = new ObjectDataSource("Risks", "RetrieveProjectRisk");
risks.TypeName = "Promanto.ProjectRisks";
risks.DataObjectTypeName = "Promanto.ProjectRisk";
risks.SelectMethod = "RetrieveProjectRisk";
risks.DeleteMethod = "DeleteProjectRisk";
risks.InsertMethod = "AddProjectRisk";
risks.UpdateMethod = "UpdateProjectRisk";
risks.SelectParameters.Add("WhereClause", TypeCode.String, "ProjectID  ='PR0002'");
RisksGrid.DataSource = risks;
RisksGrid.DataBind();

但是,当我点击编辑按钮,然后更新我的价值观,我首先得到RowUpdating应该存在一个错误。当我添加它,我不知道要放什么东西在里面。是不是我的UpdateMethodUpdateProjectRisk猜想自动闪光?

But when I click the edit button and I then update my values, I firstly get an error that RowUpdating should exist. When I add it, I'm not sure what to put in it. Isn't my UpdateMethod "UpdateProjectRisk" suppose to fire automatically?

推荐答案

当您使用 ObjectDataSource控件,提供了 UpdateMethod 是远远不够的。

When you use ObjectDataSource, providing the UpdateMethod isn't enough.

您的更新方法需要的参数,以更新哪一行。
在GridView不会自行提供这一点。

Your update method will need parameters as to which row to update. The gridview does not provide this on its own.

您需要执行 RowUpdating 来提供 UpdateParameters 需要更新你的的ObjectDataSource

You need to implement the RowUpdating to provide the UpdateParameters needed to updated your ObjectDataSource

看看这个 ObjectDataSource控件实例

这篇关于GridView的UpdateMethod不点火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆