将表单提交到非默认页面
我在另一个例子中通过一些解决方法解决了这个问题,但这次我想弄清楚,因为我更好地理解了我的问题。
我的 asp.net 网页有一个搜索功能,可以根据 5 个字段搜索数据库。结果显示在网格视图中。网格视图是可编辑的,我可以更新值。问题是如果我想更新多个值,gridview 不允许这样做。所以我为复选框添加了一个额外的列。我添加了一个页脚,其中包含更新所有已检查记录的链接。
好吧,那么问题来了?如何将整个 gridview 发送到另一个可以捕获 gridview 值的页面?
默认情况下,页面会提交到其自身上。如果我更改默认操作页面、整个网格视图和搜索,则任何操作都不起作用。
那么如何将整个页面(或部分页面)提交到默认操作脚本之外的其他页面呢?
I solved this problem in another instance by making some workaround but I want to get it clear this time as I understand my problem better.
My asp.net net page has a search functionality that searches the database based on 5 fields. The result is displayed in the gridview. The gridview is editable and I can update values. The problem is if I want to update multiple values, gridview won't allow it. So I included an extra column for checkbox. I have added a footer which has link to update all checked records.
Ok so here is the problem? How do I send the whole gridview to another page where I can capture the gridview values?
By default the page is submitted onto itself. If I change the default action page, the whole gridview and search, nothing will work.
So how do I submit the whole page (or part of it) to a different page other than the default action script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有专门用 gridview 尝试过这个,但我认为跨页回发应该可以工作。我的网站上也有搜索功能,这就是我使用的功能。
设置导致回发到目标页面的按钮的 PostBackUrl。
假设您的源页面是 search.aspx,目标页面是 SearchResult.aspx
在 search.aspx 中:
表单将发布到 SearchResult.aspx。在 SearchResult.aspx 中,您添加此指令:
在后面的代码中,您可以像这样访问任何控件:
希望这会有所帮助。
I have not tried this specifically with a gridview, but I think a Cross Page PostBack should work. I have a search feature on my website as well and this is what I use.
Set the PostBackUrl of the Button that is causing the PostBack to the Destination page.
Let’s assume your source page is search.aspx and your destination page is SearchResult.aspx
Inside search.aspx:
The form will be posted to SearchResult.aspx. Inside SearchResult.aspx, you add this directive:
And in the code behind, you can acess any control like this:
Hope this help.
您是否尝试过使用
Session
?只需将DataSource
或Gridview
本身添加到Session
并将其加载到其他页面中,然后使用Dispose()它。
祝你好运!
更新:
我过去通过Cross- 完成了此操作页面发布。这就是我现在出于测试目的所做的:
Default.aspx:
SearchResult.aspx.cs:
希望这会有所帮助。
Have you tried using the
Session
? Just add theDataSource
, or theGridview
itself to theSession
and load it in the other Page and thenDispose()
it.Good luck!
UPDATE:
I have accomplished this in the past through Cross-Page Posting. This is how I did it now for testing purposes:
Default.aspx:
SearchResult.aspx.cs:
Hopefully this helps.