小弟新手请大侠帮帮小弟.传值问题传到查询语句,查询到的结果绑定并在datalist里面显示。用session传只能传数组里面最后一个值,前面的值被覆盖。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim total_topic_num As Integer = 12
Dim test_topic_num As Integer = 5
Dim interval As Integer = total_topic_num \ test_topic_num
Dim big_interval_num As Integer = total_topic_num Mod test_topic_num
Dim array_topic_id(test_topic_num) As Integer
Dim i As Integer = 0
If big_interval_num <> 0 Then
For i = 0 To test_topic_num - 1 - big_interval_num
Randomize()
array_topic_id(i) = Int(interval * Rnd() + i * interval)
Session("id") = array_topic_id(i)用这个传值只能传数组里最后一个值
Next
For i = test_topic_num - big_interval_num To test_topic_num - 1
Randomize()
array_topic_id(i) = (test_topic_num - big_interval_num) * interval + Int((interval + 1) * Rnd() + (i - (test_topic_num - big_interval_num)) * (interval + 1))
Session("id") = array_topic_id(i)用这个传值只能传数组里最后一个值
Next
Else
For i = 0 To test_topic_num - 1
Randomize()
array_topic_id(i) = Int(interval * Rnd() + i * interval)
Session("id") = array_topic_id(i)
用这个传值只能传数组里最后一个值
Next
End If
databind1()
End If
End Sub
Sub databind1()
Dim connstr As String
connstr = ConfigurationManager.AppSettings("strconn").ToString
Dim conn As New SqlConnection(connstr)
Dim cmd As New SqlCommand("select * from shuju where id= '" & Session("id").ToString() & "' ", conn) 传到这里
conn.Open()
Dim adp As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
adp.Fill(ds, "link")
DataList1.DataSource = ds.Tables("link").DefaultView
DataList1.DataBind()
conn.Close()
End Sub
[解决办法]
session是页面之间传值吧!用这个不合适哦