好的,我真的对这个人感到愚蠢....
我有这堂课:
Public Class whatever
Public id as string
Public name as string
public date as string
end class
我使用此代码:
dim personlist as new arraylist
dim person as new whatever
person.id="1"
person.name="bozo"
person.date="6-6-6"
personlist.add(person)
然后我再说一遍,这样我就可以用我想要在gridview中显示的所有信息填充我的arraylist。
问题在于:
gridview1.datasource = personlist
gridview1.databind()
执行时,我收到错误消息:
The data source for GridView with id 'gdpersonlist' did not have any properties or attributes from which to generate columns. Ensure that your data source has content.
任何人都可以帮助我,或者让我指出正确的方向吗?!
答案 0 :(得分:4)
尝试使用属性而不是字段。网格视图的数据绑定不适用于字段。
Public Class whatever
Public _id as string
Public name as string
public date as string
Public Property Id As String
Get
Return _id
End Get
Set (value as String )
_id = value
End Set
End Property
' repeat for all 3 fields
end class