ASP.NET:如何将多个QueryString作为参数传递给Gridview

时间:2017-07-09 11:26:52

标签: asp.net vb.net gridview parameters query-string

我的链接包含像这样的QueryString

http://localhost:11502/Default.aspx?query=123,456

问题是,如何将query 123,456, etc传递给Gridview作为参数? 我在下面执行此操作,但只有第一个参数显示数据

 Dim xSplit As String = Me.Request.QueryString("query").ToString
 Dim newtstString = xSplit.Split(",")

    For a As Integer = 0 To newtstString.Length
        Dim constr As String = Me.STRCONN_STRING.ToString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand(query)
                Using sda As New SqlDataAdapter()
                    cmd.Connection = con
                    sda.SelectCommand = cmd
                    cmd.Parameters.Add("@param", SqlDbType.VarChar).Value = newtstString(a)
                    Using dt As New DataTable()
                        sda.Fill(dt)
                        Me.Gridview1.DataSource = dt
                        Me.Gridview1.DataBind()
                    End Using
                End Using
            End Using
        End Using
    Next

0 个答案:

没有答案