3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by Phasma
0

try this:

Imports System.Data
Imports System.Data.OleDb

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim con As New OleDbConnection("Connection string")
    Dim cmd As New OleDbCommand
    Dim da As New OleDbDataAdapter

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        con.Open()
        cmd = New OleDbCommand("select * from Table1", con)
        Dim dt As New DataTable
        da.SelectCommand = cmd
        da.Fill(dt)
        ListView1.DataSource = dt      
        ListView1.DataBind()

    End Sub
0

I'm not an expert but I'm pretty sure there is no DataSource property for a ListView at least not in VB2008 and framwork 3.5. I think you're going to have to loop through the datatable and add the items to the listview that way. I believe the DataGridView would work for what you want and it has a DataSource property that's very easy to implement.

Ken

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.