0

モデル クラス オブジェクトを含む 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%>
4

2 に答える 2

0

最初のアイデア:

打ち間違え?ViewData("row")ViewData("rows")

于 2012-08-26T06:06:20.320 に答える
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("rows") には ArrayList が含まれているため、このコレクションを反復処理する必要があり、ArrayList にはAppointment型のデータが含まれています。

于 2012-08-26T06:06:45.343 に答える