我的页面上有一个 GridView 控件,它与 ObjectDataSource 连接,其中 TypeName="BLL.MyLogic" DataObjectTypeName="BLL.MyObject" UpdateMethod="MyUpdateMethod"。
MyUpdateMethod 中的更新是有条件的,我在 _datacontext.submitchanges() 之前检查条件。根据我的检查,我会抛出异常(“不唯一”)或(“找不到适当的逻辑”)等。我通过 ObjectDataSource 的 OnUpdated="MyDataUpdated" 在页面级别捕获这些异常。
这些操作运行得很好。问题是在该过程完成后,即使在“发生异常”的情况下,GridView 也会重新加载并且 editindex = -1 (启动)。即使我手动检索编辑索引并使其可编辑,编辑模板中的表单数据(用户输入的数据)也会被擦除。 ViewState 在这里不起作用。
对于这种情况有什么解决办法吗?
提前致谢。
I have a GridView control on my page which is connected with ObjectDataSource where TypeName="BLL.MyLogic" DataObjectTypeName="BLL.MyObject" UpdateMethod="MyUpdateMethod".
The update in MyUpdateMethod is conditional which I am checking the conditions before _datacontext.submitchanges(). Depending on my check I throw exceptions like ("not unique") or ("no appropiate logic found") etc. I am catching these exceptions at page level via OnUpdated="MyDataUpdated" of my ObjectDataSource.
These operations just work fine. Problem is after the process is done and even in the case of "exception occured" the GridView gets reloaded and editindex = -1 (initiated). Even if I manually retrieve the editindex and make it editable the form data (data input by user) in the edittemplate gets wipped away. ViewState doesnt work here.
What is the work around to this situation ?
Thanks in advance.
发布评论
评论(1)
您是否尝试过设置 GridViewUpdatedEventArgs.KeepInEditMode 属性设置为 true?
Have you tried setting the GridViewUpdatedEventArgs.KeepInEditMode property to true in your RowUpdated event handler?