I have an arraylist, that contains model class objects. Here is how I create the array list.
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
I want to use this arraylist to generate a table of records on the view page. I tried using a for loop but I cannot access the model values like that. So please tell me, how i can solve this?
I tried doing something like this
<% 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%>
You should use
The ViewData(“rows”) contains the ArrayList so we need to iterate this collection, and the ArrayList contains the data of
Appointmenttype.