Error binding 2D array to Gridview

I want to bind a multidimensional array to gridview, but when I run " Gridview1.DataBind()"

The following error is displayed:

"The array was not a one-dimensional array."

Below is my code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        CreateArray()
End Sub

Private Sub CreateArray()

        Dim Array(4, 3) As String
            Array(0, 0) = "ABC"
            Array(1, 0) = "DEF"
            Array(2, 2) = "GHJ"
            Array(1, 3) = "XVZ"

        Gridview1.DataSource = Array       
        Gridview1.DataBind() 

End Sub

Is there an error in my code? Thank,

Joe

+3
source share
2 answers

Use a DataTable instead of a MultiDimmensional array. They will perfectly connect to the GridView (or other data controls).

http://www.issociate.de/board/goto/880762/Binding_Multidimensional_Array_to_DataGrid.html

+1
source

2D Array Gridview. Single Dimensional array, a DataTable, Collection GridView.

+1

All Articles