?
Solved

DatarowView in ListBox not always displayed correctly

Posted on 2004-04-23
3
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
Lektran earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

800 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