WhiteEagle
asked on
DatarowView in ListBox not always displayed correctly
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.