在表单视图上成功插入命令后,我试图重定向。这是我所拥有的:
细节.aspx:
<asp:FormView id="formview1"...datasourceid="detailsSQLDS">
<InsertItemTemplate>
DateOfService:
<asp:TextBox ID="DateOfServiceTextBox" runat="server"
Text='<%# Bind("DateOfService") %>' />
<br />
InsurancePrimary:
<asp:TextBox ID="InsurancePrimaryTextBox" runat="server"
Text='<%# Bind("InsurancePrimary") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
</InsertItemTemplate>
</asp:FOrmView>
....
<asp:SqlDataSource ID="detailsSQLDS" runat="server"
ConnectionString="..."
InsertCommandType="StoredProcedure"
InsertCommand="usp_Insert"
>
代码背后:
protected void formview1_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
Response.Redirect( "List.aspx?mrn=" + Request.QueryString["mrn"] );
}
插入工作正常,但不是重定向。我认为它不会触发函数 formview1_ItemInserted(....)。有没有办法告诉formview在成功插入后触发这个函数,或者其他方法?谢谢!