[英]How do I link to an ASP:DetailsView's Insert mode via an external page
Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on one page, and it links to a 2nd page to do the edit/update view, sending the ID for the record in the GET string. 与许多ASP.NET文档和示例不同,我在一个页面上执行gridview列表,它链接到第二页以执行编辑/更新视图,在GET字符串中发送记录的ID。
On my edit/update view, I'm using an ASP:DetailsView for viewing, editing and inserting records. 在我的编辑/更新视图中,我使用ASP:DetailsView来查看,编辑和插入记录。 All of this works fine.
所有这一切都很好。
On the detailsView
page, I have it autogenerating a new record
link that uses postback to show the blank insert form to be filled out. 在
detailsView
页面上,我让它自动生成一个new record
链接,该链接使用回发来显示要填写的空白插入表单。
The only problem is, I have no idea how to link to the insert
view of the DetailsView
from an external page. 唯一的问题是,我不知道如何从外部页面链接到
DetailsView
的insert
视图。 Am I missing something? 我错过了什么吗?
I could have misunderstood your question but.... 我本可以误解你的问题,但....
I don't believe you can 'link to the insert view', but what you can do is programmatically change the mode of the DetailsView once the page has loaded. 我不相信你可以“链接到插入视图”,但你可以做的是在页面加载后以编程方式更改DetailsView的模式。 Remember to check that the passed in ID has a value first.
请记住检查传入的ID是否具有值。
For example: 例如:
If Not idValue Is Nothing Then
yourDetailsViewName.ChangeMode(DetailsViewMode.Insert)
End If
Check out the MSDN page for more info: 查看MSDN页面了解更多信息:
DetailsView.ChangeMode Method DetailsView.ChangeMode方法
I just wanted to follow up and say that, even though I did not find a way to link to a specific page state, I did discover the dataview's DefaultMode parameter, that at least allows you to pick an initial state. 我只是想跟进并说,即使我没有找到链接到特定页面状态的方法,我确实发现了dataview的DefaultMode参数,至少可以让你选择一个初始状态。
Thus: DefaultMode="Insert" 因此:DefaultMode =“Insert”
At least lets you choose insert mode as the default. 至少允许您选择插入模式作为默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.