Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link an ArrayList to a GridView control on web page

Status
Not open for further replies.

KerryC

Technical User
Apr 9, 2002
36
CA
I'll preface this by saying that up to now, I've done some VB.Net programming for Windows applications, but this is my firs foray into web, ASP etc.

Using vb.net 2008 I am trying to use a GridView on a web page to display the contents (properties) of objects contained in an ArrayList called 'SampleList'. (The arraylist is actually a myArrayList derived from ArrayList because I wanted it to be serializable.)

I set the gridview.datasource property to my arraylist, using:

Code:
Gridview1.DataSource = SampleList
Gridview1.DataBind()

But on the databind statement I get an error saying "The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content."

I've added several objects to the arraylist and verified that they are there by adding the concatenated string properties to a listbox, which displays fine.

The objects in my ArrayList are defined as follows:
Code:
 <Serializable()> _
    Public Class OneSample
        'Contains information about a single sample
        Private _Submission As String
        Private _SampleCode As String
        Private _SampleDate1 As String
        Private _SubstanceCode As String
        Private _Status As String
        Public Property Submission()
            Get
                Return _Submission
            End Get
            Set(ByVal value)
                _Submission = value
            End Set
        End Property
        Public Property SampleCode() ...
        Public Property SampleDate1() ...
        Public Property SubstanceCode() ...
        Public Property Status() ...
        Public Property Concat() ...
        Public Function Concatenated ...
    End Class
I've done a lot of searching the net but just can't understand why I'm still getting this error.

Any assistance would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top