Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

gridview and arraylist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Devlon - 09 Apr 2008 15:49 GMT
Hi,

I would like to bind a gridview to an arraylist, which contains a  
collection of custom objects.
I've created a gridview, which has a "Name" column and the text field  
property set to "Name".

The code I used ....

        Dim myList As New ArrayList()

        Dim myPerson As clsPerson

        myPerson = New clsPerson
        myFile.Name = "John"

        myList.Add(myFile)

        GridView1.DataSource = myList
        GridView1.DataBind()

When running the code, an error is trown on the databind line... "there is  
no field or property with the name "Name" in the selected source
"

Can anyone please help me ?

John
John Devlon - 09 Apr 2008 15:52 GMT
Hi,

I just noticed a small error in the example code...

>          Dim myList As New ArrayList()
>
[quoted text clipped - 7 lines]
>          GridView1.DataSource = myList
>          GridView1.DataBind()

Does anyone have an idea ? It's not working...

John
Matthijs Krempel - 09 Apr 2008 16:07 GMT
Hi John,

Is the name property public?

It's also better to use a generic list, like: List<Person>

With kind regards,

Matthijs Krempel

> Hi,
>
[quoted text clipped - 15 lines]
>
> John
Eliyahu Goldin - 09 Apr 2008 16:09 GMT
This looks fine. Apparently there is a problem in other parts of the code.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

Hi,

I just noticed a small error in the example code...

>          Dim myList As New ArrayList()
>
[quoted text clipped - 7 lines]
>          GridView1.DataSource = myList
>          GridView1.DataBind()

Does anyone have an idea ? It's not working...

John
John Devlon - 09 Apr 2008 23:39 GMT
Hi,

I've tried changing the list definition to

        Dim mylist As New List(Of clsPerson)

... but it doesn't seem to work..

The same error occures...

Does anyone have an idea?

Thanx

John

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.