나는 모델 클래스 개체를 포함하는 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%>
보기 페이지에서 '약속'을 얻을 수 없습니다. – mrN
모델 클래스의 네임 스페이스 (예 : ** SolutionName.Models.Appointment **)로 Appointment를 얻을 수 있습니다. –