好吧,我对这件事真的很傻……
我有这样一门课:
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)然后我重复一遍,这样我就可以用我想要在网格视图中显示的所有信息填充我的数组列表。
问题是:
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.有没有人能帮我或者给我指出正确的方向?!
发布于 2009-06-18 17:00:32
尝试使用属性而不是字段。网格视图的数据绑定不适用于字段。
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 classhttps://stackoverflow.com/questions/1013881
复制相似问题