Solved

DatarowView in ListBox not always displayed correctly

Posted on 2004-04-23
3
222 Views
Last Modified: 2010-04-24
I have an application where the Datasource of a ListBox is a datatable or a dataview.

Sometimes when the list box is displayed it shows the 5 items correctly, at other time it shows System.Data.DataRowView as the text for each item. How can I ensure that it always shows teh text correctly?

Sub PopulateGlobeList(ByRef r_lst As ListBox)

            Dim oKey(0) As System.Data.DataColumn
            Dim tblGlobe As DataTable

            r_lst.BeginUpdate()

                '  Creat and populate data table
                  .......

                ' Set key and sort info
                oKey(0) = tblGlobe.Columns("GlobeID")
                tblGlobe.PrimaryKey = oKey
                tblGlobe.DefaultView.Sort = "GlobeText"

                ' ---- and bind to the the list box
                r_lst.DataSource = tblGlobe.DefaultView
                r_lst.ValueMember = "GlobeID"
                r_lst.DisplayMember = "GlobeText"

            r_lst.EndUpdate()

End Sub
0
Comment
Question by:WhiteEagle
3 Comments
 
LVL 3

Accepted Solution

by:
Lektran earned 50 total points
ID: 10907041
the only time i have that problem occur is if i have not yet set the displaymember property or if i have set it incorrectly
it might pay to spend some time testing to see what is different when the list displays correctly and incorrectly

p.s im pretty sure you dont need to include the DefaultView part of your datasource you should find that the data will display as sorted without it
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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