Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

need help transfering data table to listbox.

$
0
0

Here is vb code. data table loads OK, listbox does not. data table row has two fields:

mccode int

census  decimal (8,0)

Can anyone please help?

Dim dt As New DataTable()
        Dim sql = Session("buildquery")
        Dim da As New SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings("BerksConnectionString").ToString())
        Dim RowCount As Integer
        da.Fill(dt)
        Dim dv As DataView = dt.DefaultView
        Int(RowCount = dt.Rows.Count)
        If dt.Rows.Count < 1 Then
            LblError.Text = "no census records were found. Suggest broadening query and retry "
        End If
        ' data table is now loaded with data, works OK
       
       
        ListBox3.DataTextField = "mccode"
        ListBox3.DataValueField = "census"
        ListBox3.DataSource = dt.DefaultView
        ListBox3.DataBind()
       
        'at this point listbox3 should be loasded with data table rows, but it is not


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>