Hi
I am trying to pass the datatable of a search query to another page and bind it to a listbox. The problem is the the listbox just displays system.data.datarowview and no results.

I have listed the code below.

Thanks

First page SQL and session store:

Protected Sub btnSearch_Click(sender As Object, e As System.EventArgs) Handles btnSearch.Click
        Dim ConnString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString()


        Dim connection As New SqlConnection(ConnString)

        
        Dim adapter As New SqlDataAdapter("SELECT VideoName, VideoNo FROM Video where VideoName='" & txtSearch.Text & "'", connection)

        Dim dt As New DataTable
        adapter.Fill(dt)

        Session("Results") = dt

        Response.Redirect("search_results.aspx")
        
    End Sub

Second page loading the session

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

        If Session("Results") IsNot Nothing Then

            Dim dtnew As DataTable = DirectCast(Session("Results"), DataTable)


            lstResults.DataSource = dtnew

            'listbox data
            lstResults.DataMember = "VideoName"
            'bind the listbox
            lstResults.DataBind()

        Else
            lblerror.Text = "No Results"
        End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.