首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >插入CommandArgument on SQLDatasource?

插入CommandArgument on SQLDatasource?
EN

Stack Overflow用户
提问于 2014-11-05 18:11:41
回答 1查看 77关注 0票数 0

我希望重定向到两个不同的页面,这取决于在我的表单上按下哪个按钮。

两个按钮都调用Datasource的Insert方法,但其中只有一个按钮需要获得新插入的GUID并使用该GUID重定向。

我是用这个代码做的

代码语言:javascript
复制
Protected Sub DSCustomers_Inserted(sender As Object, e As SqlDataSourceStatusEventArgs) Handles DSCustomers.Inserted
        Response.Redirect("~/addTicket.aspx?step=2&customerID=" & e.Command.Parameters("@customerID").Value.ToString)
End Sub

但是,我如何知道是否是另一个按钮已经按下,而不需要重定向?

我无法访问CommandArgument,否则我只需检查哪个按钮已被按下,然后相应地重定向。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-05 18:18:36

你不能只使用全局私有布尔值吗?

代码语言:javascript
复制
Dim RedirectButtonPressed As Boolean = false

Protected Sub RedirectButton_Click(sender As Object, e As EventArgs) Handles RedirectButton.Clicked
    // code code code
    RedirectButtonPressed = True
End Sub

Protected Sub DSCustomers_Inserted(sender As Object, e As SqlDataSourceStatusEventArgs) Handles DSCustomers.Inserted
    If RedirectButtonPressed Then
        Response.Redirect("~/addTicket.aspx?step=2&customerID=" & e.Command.Parameters("@customerID").Value.ToString)
        RedirectButtonPressed = False
    End If
End Sub
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26764160

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档