我发现,在 ASP.NET 页面中的简单表单上,我可以通过将表单字段包含到 Panel 控件中并设置其默认按钮来通过按 Enter 键来提交其值。
但是我怎样才能为 DetailsView 做到这一点?我想在插入时通过插入按钮提交,在更新时通过更新按钮提交。
我发现,在 ASP.NET 页面中的简单表单上,我可以通过将表单字段包含到 Panel 控件中并设置其默认按钮来通过按 Enter 键来提交其值。
但是我怎样才能为 DetailsView 做到这一点?我想在插入时通过插入按钮提交,在更新时通过更新按钮提交。
您可以尝试使用DefaultButton property
(默认提交按钮)
<asp:Panel ID="panel1" runat="server" defaultbutton="Button1">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" />
</asp:Panel>
链接:http: //msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.panel.defaultbutton.aspx
你也可以定义AccessKey property
链接:http: //msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.webcontrol.accesskey.aspx