2009-06-18 2 views
0

, 좋아 I'me 바인딩 ArrayList를 (파트 무엇이든 ....)

나는이 수업이 ....이 하나 진짜 바보 점점 : 내가 사용하는

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. 

이 사람이 나를 도울 혹은이 작업을 수행 할 수있는 올바른 방향으로 날 포인트를!

답변

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 
+0

Beautiful, thanks man. – v3ga