I want to load database tables in dropdown list and display selected table in grid view. I am trying to convert the following code into asp. Net.

I am getting error as, 
Variable conflicts with property adapter 
Private adapter As New OleDbDataAdapter(String.Empty, Me.con)

                                                                                                                   DisplayMember' is not a member of 'System.Web.UI.WebControls.DropDownList'        ValueMember' is not a member of 'System.Web.UI.WebControls.DropDownList'.          Me.DropDownList1.DisplayMember = "TABLE_NAME"
                                                                                                                   can someone help me in this regard?




Public Class WebForm1
 Inherits System.Web.UI.Page


    Private con As New OleDbConnection("  Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\dtb.accdb;Jet OLEDB:Database Password=****  ")
    Private adapter As New OleDbDataAdapter(String.Empty, Me.con)
    Private data As DataTable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        con.Open()

        Me.DropDownList1.DisplayMember = "TABLE_NAME"
        Me.DropDownList1.ValueMember = "TABLE_NAME"
        Me.DropDownList1.DataSource = Me.con.GetSchema("TABLES", New String() {Nothing, Nothing, Nothing, "TABLE"})
        con.Close()
    End Sub



    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        If Me.DropDownList1.SelectedItem IsNot Nothing Then
            Me.data = New DataTable
            Me.adapter.SelectCommand.CommandText = String.Format("SELECT * FROM [{0}]", Me.DropDownList1.SelectedValue)
            Me.adapter.Fill(data)
            Me.GridView1.DataSource = Nothing
            Me.GridView1.Columns.Clear()
            Me.GridView1.DataSource = Me.data
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        ' Dim thisConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Dtb.accdb")

        If Me.data IsNot Nothing Then
            Dim builder As New OleDbCommandBuilder(Me.adapter)
            Me.adapter.Update(Me.data)
        End If
    End Sub

DisplayMember and valueMember aren't properties of the DropDownList.
You simply can't use them as they aren't relevant to that control.

thank you for your reply
I have one more question, how do i fix the error
Variable conflicts with property adapter
Private adapter As New OleDbDataAdapter(String.Empty, Me.con)

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.