Solved

DatarowView in ListBox not always displayed correctly

Posted on 2004-04-23
3
215 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

12 Experts available now in Live!

Get 1:1 Help Now