getting the display member from a selected item in my listbox

Posted on 2011-05-12
Last Modified: 2012-06-27

I have the following code:
For i = 0 To lstLineFinder.Items.Count - 1
            dr = _tblSelectedLines.NewRow

            dr.Item("Line ID") = lstLineFinder.Items.Item(i).ToString


I am binding the datatable to my gridview but that field is being displayed as:

What am I doing wrong?

I need the value of the selected item?!
Question by:scm0sml
    1 Comment
    LVL 83

    Accepted Solution

    Try changing

    dr.Item("Line ID") = lstLineFinder.Items.Item(i).ToString


    dr.Item("Line ID") = lstLineFinder.Items.Item(i)(0)

    where 0 means first column

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now