Response.Redirect - 操作方法

时间:2013-10-02 17:57:16

标签: asp.net vb.net

我正在尝试弄清楚如何使用ASP.NET VB中的“Response.Redirect”从gridview中获取两列,如果可能,从同一页面上的下拉列表中将其发送到下一个标签页。这可能吗?

此外,我还有点理解“Room& Name”的位置。我在哪里找到正确的输入?谢谢你的帮助。

已更新:

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged

    Response.Redirect("RoundingEntry.aspx?Room=" & GridView1.SelectedRow.Cells(1).Text & "&Name=" & GridView1.SelectedRow.Cells(2).Text & "&Rounder=" & DDRounder.SelectedValue)

    End Sub

在我的下一页/接收页面上,我有这个...

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Me.Page.PreviousPage IsNot Nothing Then
        Dim rowIndex As Integer = Integer.Parse(Request.QueryString("RowIndex"))
        Dim GridView1 As GridView = DirectCast(Me.Page.PreviousPage.FindControl("GridView1"), GridView)
        Dim row As GridViewRow = GridView1.Rows(rowIndex)

        Dim room As String = Request.QueryString("Room")
        Dim name As String = Request.QueryString("Name")
        Dim Rounder As String = Request.QueryString("Rounder")
        lblRoom.Text = room
        lblPatientName.Text = name
        lblRounder.Text = Rounder

    End If
End Sub

lblRoom.Text的源代码

<asp:Label ID="lblRoom" runat="server" BackColor="White" Height="22px" 
     Width="100px" BorderColor="#CCCCCC" BorderStyle="Inset" BorderWidth="1pt" 
     style="text-align: center; background-color: #CCCCCC;"></asp:Label>

1 个答案:

答案 0 :(得分:1)

如果您想要上一页控件中的值,可以使用Server.Transfer("page.aspx")

如果您通过querystring,请使用Request.QueryString("Room")&amp; Request.QueryString("Name")

看看这个article

你在这里缺少RowIndex ......

Response.Redirect("RoundingEntry.aspx?Room=" & GridView1.SelectedRow.Cells(2).Text & "&Name=" & GridView1.SelectedRow.Cells(3).Text "&RowIndex=?")

然后在下一页......

Dim rowIndex As Integer = Integer.Parse(Request.QueryString("RowIndex"))
Dim room As String = Request.QueryString("Room")
Dim name As String = Request.QueryString("Name")
lblRoom.Text = room 
lblName.Text = name