创建列表时尝试添加新列表项时保存冲突错误

发布于 2024-09-04 02:22:16 字数 594 浏览 2 评论 0原文

我们使用Feature.xml、Element.xml、Schema.xml、AllItems.aspx 和3 个aspx 表单以编程方式创建了自定义列表模板。我们为每个 aspx 文件都有一个代码隐藏文件。即 AllItems.aspx、DispForm.aspx、EditForm.aspx 和 NewForm.aspx。

有问题的文件是 AllItems.aspx。在 AllItems.aspx 文件的后面代码中,我们将删除以前的列表项并将新项添加到列表中,然后再向用户显示它们。正如预期的那样,AllItems.aspx 文件背后的代码源自 WebPartPage 类,我们尝试重载相当多的方法,但没有取得太大成功。

问题仅发生在第一次渲染时,即创建此列表的实例时。当重写 OnLoad() 时,我们会收到 Save 冲突错误,与 OnInit()、CreateChildControls() 方法的情况类似。但是,当我们重写 Render() 或 RenderChildren() 方法时,不会出现此类错误,但同时我们的新列表项也不可见。刷新浏览器后,一切都开始按预期正常工作。这只是第一次出现这个问题。

造成这种情况的可能原因是什么?任何想法、建议将不胜感激。

最好的问候,

拉古

We have created a Custom List template programmatically using Feature.xml, Element.xml, Schema.xml AllItems.aspx, and 3 aspx forms. We have a code behind file for each of these aspx files. i.e. for the AllItems.aspx, DispForm.aspx, EditForm.aspx and NewForm.aspx.

Problematic file is AllItems.aspx. In the code behind for AllItems.aspx file we are deleting previous list items and adding new items to the list before showing them up to the user. As per expectations the code behind file for AllItems.aspx is derived from WebPartPage Class and we have tried to overload quite a few methods without much success.

Problem only occurs on the first time rendering i.e. when an instance of this list is created. When overriding OnLoad(), we get the Save conflict error, Similar is the case with OnInit(), CreateChildControls() method. However, when we override the Render() or RenderChildren() method no such error comes up but at the same time our new list items are also not visible. On browser refresh everything starts working fine as expected. It is only for the first time that the issue comes up.

What could be the possible cause for this? Any ideas, suggestions would be highly appreciated.

Best Regards,

Raghu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伴我老 2024-09-11 02:22:16

我在使用自定义 EditForm.aspx 时遇到问题。我有两个链接在一起的列表,其中一个列表的更改会导致事件处理程序更新另一个列表。我在 EditForm.aspx 中有一个自定义控件来编辑链接列表。这导致事件处理程序更新 EditForm.aspx 显示的项目。这反过来会在用户保存表单时导致冲突错误。

我终于发现我可以重置上下文:

SPContext.Current.ResetItem();

我不确定这是否对您的情况有帮助,但它解决了我的问题。

I had a problem with a custom EditForm.aspx. I have two lists that are linked together and a change in one causes an event handler to update the other. I have a custom control in EditForm.aspx that edits the linked list. This was causing the event handler to update the item displayed by EditForm.aspx. This in turn would cause the conflict error when the user saved the form.

I finally found that I could reset the context with:

SPContext.Current.ResetItem();

I am not sure if this will help in your case but it fixed my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文