2012-08-26 3 views
0

나는 모델 클래스 개체를 포함하는 arraylist가 있습니다. 다음은 배열 목록을 만드는 방법입니다.Vb.net에서 Model 클래스의 ArrayList를 반복합니다.

Dim arr As New ArrayList 
Dim citizenHelper As New CitizensHelper 
While dr.Read 
    Dim appointment As New Appointment 
    appointment.AppointmentId = dr("appointment_id") 
    appointment.DoctorNin = dr("doctor_nin") 
    appointment.DoctorName = citizenHelper.getNameByNin(dr("doctor_nin")) 
    appointment.PatientNin = dr("patient_nin") 
    appointment.PatientName = citizenHelper.getNameByNin(dr("patient_nin")) 
    appointment.BookingDate = dr("booking_date") 
    If dr("cancelled") Is "1" Then 
     appointment.Cancelled = True 
    End If 
    If dr("active") Is "1" Then 
     appointment.Active = True 
    End If 
    arr.Add(appointment) 'I add to the array like this 
End While 
ViewData("row") = arr 

이 arraylist를 사용하여보기 페이지에서 레코드 테이블을 생성하려고합니다. for 루프를 사용해 보았지만 그런 모델 값에 액세스 할 수 없습니다. 그러니 제발, 어떻게 해결할 수 있을까요?

나는이

<% For Each ap As ArrayList In ViewData("row")%> 
    <tr> 
     <td> 
      ...... <!-- Now I want to show those value from a table here --> 
     </td> 
    </tr> 
<% Next ap%> 

답변

0

우리는이 컬렉션을 반복 할 필요가 있도록

<% For Each ap As Appointment In ViewData("rows") As ArrayList %> 
<tr> 
    <td> 
     ...... <!-- Now I want to show those value from a table here --> 
    </td> 
</tr> 
<% Next ap%> 

을 ViewData ("행") ArrayList에 포함되어 사용해야하고, ArrayList를이 Appointment 유형의 데이터가 포함되어 있습니다.

+0

보기 페이지에서 '약속'을 얻을 수 없습니다. – mrN

+0

모델 클래스의 네임 스페이스 (예 : ** SolutionName.Models.Appointment **)로 Appointment를 얻을 수 있습니다. –

0

처음 생각처럼 일을 시도 :

오타? ViewData("row")ViewData("rows")?

+0

예. 오타입니다. 죄송합니다. – mrN

+0

문제가 해결 되나요?! – TheHe

+0

아니요, 그렇지 않습니다. – mrN

관련 문제