DotNetNuke ObjectDataSource.SelectMethod 未保存在视图状态中
我正在使用 DotNetNuke 4.9.2 并且遇到了一个奇怪的问题。
我正在开发的模块中有一个 MultiView,并且其中一个视图有一个绑定到 ObjectDataSource 的 GridView。
在单独的视图中,我有几个按钮可以在第二个视图中切换 ObjectDataSource 的 SelectMethod,然后将该视图设置为活动状态。 一切正常,直到网格在第二个视图上排序 - 这会导致回发并且 ODS 以某种方式拾取其原始 SelectMethod。 不过,在代码隐藏中同时分配的 SelectParameters 仍然存在。
在我看来,ObjectDataSource 应该记住视图状态中的 SelectMethod,不是吗?
<asp:ObjectDataSource runat="server" ID="MyObjectDataSource" SelectMethod="MyFirstSelectMethod" TypeName="Whatever"></asp:ObjectDataSource>
protected void Button1_Click(object sender, EventArgs e)
{
MyObjectDataSource.SelectMethod = "MyNewMethod";
// more code here to change the parameters as well...
MyMultiView.SetActiveView(MyView2);
}
当我单击该按钮时,网格将按预期显示。 当我单击 GridView 的列标题之一并中断页面加载以检查 SelectMethod 时,它已恢复为标记中声明的标题。
关于我的问题可能在这里有什么建议吗?
I'm using DotNetNuke 4.9.2 and am running into an odd issue.
I have a MultiView in the module that I'm developing, and in one of the views have a GridView that is bound to an ObjectDataSource.
In a separate view, i have several buttons that will switch the SelectMethod of the ObjectDataSource in the 2nd view and then set that view active. That all works fine, until the grid is sorted on the 2nd view - which causes a postback and the ODS somehow picks up its original SelectMethod. The SelectParameters that are assigned at the same time in the code-behind stick though.
Seems to me that the ObjectDataSource should be remembering the SelectMethod in viewstate, shouldn't it?
<asp:ObjectDataSource runat="server" ID="MyObjectDataSource" SelectMethod="MyFirstSelectMethod" TypeName="Whatever"></asp:ObjectDataSource>
protected void Button1_Click(object sender, EventArgs e)
{
MyObjectDataSource.SelectMethod = "MyNewMethod";
// more code here to change the parameters as well...
MyMultiView.SetActiveView(MyView2);
}
When I run that button click, the grid displays as expected. When I click on one of the column headers for the GridView and break in the page load to inspect the SelectMethod, it has reverted to the one declared in the markup.
Any suggestions as to what my problem could be here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜您已经确保页面重新加载时没有重置 .SelectMethod ?
I'm guessing you've made sure that you're not resetting .SelectMethod when the page reloads?
我最终通过仅使用页面属性来保存 selectmethod 来解决这个问题,然后在每次回发时重置它......
仍然不确定为什么 SelectMethod 属性不坚持在 nuke 中的回发上。 我确信这在过去的 ASP.NET 项目中对我来说效果很好......
I ended up working around the issue by just using a page property to hold the selectmethod, and then resetting it on each postback...
Still not sure why that SelectMethod prop doesn't stick on a postback in nuke. I'm sure this has worked fine for me in straight asp.net projects in the past...