vb.net 将值从一个aspx发送到另一个aspx

发布于 2024-08-20 01:26:35 字数 995 浏览 6 评论 0原文

这是我的 vb.net 代码 -

在我的子例程中 -

Private Sub xxx()

Sqlstr = "SELECT * FROM table"
            ExecuteNonQuery(Sqlstr)
SqlCmd = New SqlCommand(Sqlstr, SqlCnn)
            SqlDR = SqlCmd.ExecuteReader
            If SqlDR.HasRows Then
                Do While SqlDR.Read()
                    r = New TableRow

                    Dim l As New LinkButton
                    l.Text = SqlDR("column_name")
                    l.Attributes.Add("onClick", "setAction(" + CStr(SqlDR("id")) + ",'edit')")
                    l.ID = SqlDR("id")

                    c = New TableCell
                    c.Controls.Add(l)
                    r.Cells.Add(c)
....

因此,当人们单击我在此处提供的超链接时,我转到 page_load 并执行此操作,

If (Me.pageAction.Value = "edit") Then
               Response.Redirect("next.aspx?id=" ???? - i dont know what to put here.
            End If

我希望 next.aspx 页面具有单击的编辑值上(所以ID值)

我做这整件事是正确的还是有人有更好的解决方案,更简单和更干净的解决方案?

this is my vb.net code -

in the subroutine i have -

Private Sub xxx()

Sqlstr = "SELECT * FROM table"
            ExecuteNonQuery(Sqlstr)
SqlCmd = New SqlCommand(Sqlstr, SqlCnn)
            SqlDR = SqlCmd.ExecuteReader
            If SqlDR.HasRows Then
                Do While SqlDR.Read()
                    r = New TableRow

                    Dim l As New LinkButton
                    l.Text = SqlDR("column_name")
                    l.Attributes.Add("onClick", "setAction(" + CStr(SqlDR("id")) + ",'edit')")
                    l.ID = SqlDR("id")

                    c = New TableCell
                    c.Controls.Add(l)
                    r.Cells.Add(c)
....

so when the person clicks on the hyperlink that i have provided here, i goto page_load and do this

If (Me.pageAction.Value = "edit") Then
               Response.Redirect("next.aspx?id=" ???? - i dont know what to put here.
            End If

i want the next.aspx page to have the value of edit that was clicked on (so the ID value)

Am i doing this whole thing right or does someone have a better solution, simpler and cleaner one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪花飘飘的天空 2024-08-27 01:26:35
Response.Redirect("next.aspx?Field=Value&AnotherField=AnotherValue")

要将其返回到下一页:

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim field As String = Request.QueryString("Field")
    Dim anotherField As String = Request.QueryString("AnotherField")
End Sub

您可能想看看这篇文章 了解更多详情。

Response.Redirect("next.aspx?Field=Value&AnotherField=AnotherValue")

To get it back in the next page:

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim field As String = Request.QueryString("Field")
    Dim anotherField As String = Request.QueryString("AnotherField")
End Sub

You might wanna ahve a look at this article for further details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文