troubleshooting Question

ComboBox displays System.Data.DataRowView but DatagridView databinds fine

Avatar of clintnash
clintnashFlag for United States of America asked on
.NET ProgrammingVisual Basic.NET
6 Comments1 Solution1409 ViewsLast Modified:
I have a combobox on my winform, I am retrieving data from an XML file and serializing it into an object, as it reads in the XML file, I am inserting each row into a datatable.  I am down to the point that I have created the datatable from scratch, added each column and row and I am still geting system.Data.DataRowView on every row of the combobox.  I bind it to a datagridview and it works just fine and the column names look exact.  Any input on this will be greatly appreciated.

            Dim Mydatatable As DataTable = New DataTable()
            Dim MyDataView As DataView

            Dim MyDataColumn As DataColumn = New DataColumn
            Dim MyDataColumn2 As DataColumn = New DataColumn

            Dim myrow As DataRow

            MyDataColumn.DataType = Type.GetType("System.Int32")
            MyDataColumn.AllowDBNull = False
            MyDataColumn.Caption = "SportID"
            MyDataColumn.ColumnName = "SportID"
            MyDataColumn.Unique = True


            MyDataColumn2.DataType = Type.GetType("System.String")
            MyDataColumn2.AllowDBNull = False
            MyDataColumn2.Caption = "Sport"
            MyDataColumn2.ColumnName = "Sport"

            Dim dehydrated As FileStream = New FileStream("..\..\AppData\Sports1.xml", FileMode.Open)
            Dim serialize As XmlSerializer = New XmlSerializer(GetType(AllSports))
            Dim mySports As AllSports = New AllSports
            mySports = serialize.Deserialize(dehydrated)
            Dim SingleSport As Sport
                  For Each SingleSport In mySports.MultipleSports
                        myrow = Mydatatable.NewRow
                        myrow("SportID") = SingleSport.SportID
                        myrow("Sport") = SingleSport.Name
            Catch ex As Exception
            End Try


            MyDataView = New DataView(Mydatatable)
                                'this is the combobox that doesn't display the data.
            cbSports.ValueMember = "SportID"
            cbSports.DisplayMember = "Sport"
            cbSports.DataSource = MyDataView

            DataGridView1.DataSource = MyDataView


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros