我的链接包含像这样的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