We help IT Professionals succeed at work.
Get Started

Bind single column table to drop down list

584 Views
Last Modified: 2012-08-13
I'm missing something simple here. My code is collecting the appropriate data (verified this using breakpoints), but my drop down list populates each item with the text System.Data.DataRowView instead of the actual string value.
MultiView1.ActiveViewIndex = 1

        Dim Table1 As DataTable
        Table1 = New DataTable("DAT List")

        Dim datFiles As DataColumn = New DataColumn("Files")
        datFiles.DataType = System.Type.GetType("System.String")
        Table1.Columns.Add(datFiles)

        Dim datFile As String() = IO.Directory.GetFiles(txtPath.Text & "\SnapDriveInfo\")
        Dim file = From p In datFile Where p.Contains(".dat") Select p


        For Each log In file
            txtOut.Text &= log
            txtOut.Text &= vbCrLf
            Dim Row1 As DataRow
            Try
                Row1 = Table1.NewRow()
                Row1.Item(datFiles) = log
                Table1.Rows.Add(Row1)
            Catch ex As Exception

            End Try


        Next

        drpDatFiles.DataSource = Table1
        drpDatFiles.DataBind()

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE