We help IT Professionals succeed at work.

dataset and datatables bind as "System.Data.DataRowView" instead of values

cyimxtck
cyimxtck asked
on
1,062 Views
Last Modified: 2012-05-05
The correct number of rows is always returned but the output is the same for every row: "System.Data.DataRowView"

Can someone please explain to me why this is happening?

Any help is greatly appreciated.

Thanks,

B

Here is the function.  (I know it should be a sub, I just did this for quick illustration.)

    Protected Function YesNo() As DataSet

        Dim dt As DataTable
        dt = New DataTable("ColumnVal")
        Dim Row1, Row2, Row3 As DataRow

        Try
            Dim Name As DataColumn = New DataColumn("Name")
            'Name.DataType = System.Type.GetType("System.String")
            dt.Columns.Add(Name)

            Row1 = dt.NewRow()
            Row1.Item("Name") = sel.ToString
            dt.Rows.Add(Row1)

            Row2 = dt.NewRow()
            Row2.Item("Name") = "Yes".ToString
            dt.Rows.Add(Row2)

            Row3 = dt.NewRow()
            Row3.Item("Name") = "No".ToString
            dt.Rows.Add(Row3)
        Catch

        End Try

        Dim ds As New DataSet()
        ds = New DataSet()

        ds.Tables.Add(dt)

        cbo1.DataSource = ds.Tables("ColumnVal")
        cbo1.DataBind()

        Return ds

    End Function
Comment
Watch Question

Commented:
Set ComboBox DisplayMember to column name.

Goran

Author

Commented:
Can you provide this example in the above code?

Thanks,

B
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
perfect!  That one line can ruin your code you know...  :)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.