473,467 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

gridview and arraylist



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
Apr 9 '08 #1
4 1608

Hi,

I just noticed a small error in the example code...
Dim myList As New ArrayList()

Dim myPerson As clsPerson

myPerson = New clsPerson
myPerson.Name = "John"

myList.Add(myPerson)

GridView1.DataSource = myList
GridView1.DataBind()
Does anyone have an idea ? It's not working...

John

Apr 9 '08 #2
Hi John,

Is the name property public?

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

With kind regards,

Matthijs Krempel

"John Devlon" <jo********@hotmail.comschreef in bericht
news:op***************@laptoptim.wag325n...
>
Hi,

I just noticed a small error in the example code...
> Dim myList As New ArrayList()

Dim myPerson As clsPerson

myPerson = New clsPerson
myPerson.Name = "John"

myList.Add(myPerson)

GridView1.DataSource = myList
GridView1.DataBind()

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

John
Apr 9 '08 #3
This looks fine. Apparently there is a problem in other parts of the code.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"John Devlon" <jo********@hotmail.comwrote in message
news:op***************@laptoptim.wag325n...

Hi,

I just noticed a small error in the example code...
Dim myList As New ArrayList()

Dim myPerson As clsPerson

myPerson = New clsPerson
myPerson.Name = "John"

myList.Add(myPerson)

GridView1.DataSource = myList
GridView1.DataBind()
Does anyone have an idea ? It's not working...

John


Apr 9 '08 #4


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
Apr 9 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ianstirkcv | last post by:
Hi, Does anyone have an ASP 2.0 code sample that shows how to bind a one-dimensional array to a GridView, such that the rows are shown as hyperlinks? Thanks Ian
4
by: rjl | last post by:
Is there a way to assign an arraylist inside an arraylist as a column? i have arrayList list, which has 2 Strings and an arrayList with 3 values. I would like the following columns then in a...
3
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView =...
1
by: Mike Collins | last post by:
I've seen how to set up a gridview at design time, but I believe I need to do this and run time and cannot figure it out. I am sending a concatenated list of IDs that is gets bigger each time a...
3
by: pblack9455 | last post by:
I have a simple requirement to bind a small ArrayList of (ItemLine) Objects to a GridView control. The Gridview renders on the page and allows me to click update/edit buttons...however the data...
1
by: pblack9455 | last post by:
Is it possible to do the following:- Create an ObjectDataSource object that has an embedded ArrayList of Objects. Allow the ASP.NET application to create and populate an instance of the...
1
by: =?Utf-8?B?UGF0cmljayBG?= | last post by:
I have a gridview on the page that i want to dynamically populate with radiobuttons, so i went out on the net and found something that works perfectly, it created radionuttons and the postback with...
5
by: Tim Mackey | last post by:
hi, with a derived DataGrid control, i can override the CreateColumnSet method and scan into the DataGridColumns and set the DataFormatString, e.g. leave out the time part of a DateTime value. ...
1
by: =?Utf-8?B?SmF5Qw==?= | last post by:
I am trying to understand how to use an arraylist that contains data in a structure and bind the results to a gridview. Using vs2008 I have looked at the examples 315784 HOW TO: Bind a DataGrid...
1
by: nomad | last post by:
Hi, I have a two dimensional arraylist below, which I am trying to bind to a gridview. However, when I try and do this the gridview is being populated with what looks like property values i.e....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.