1

我有一个列表,其中包含许多对象。我想逐步完成它,并为每个我想创建一行的对象。基本上我想要一张桌子。谁能帮帮我吗。

           List<Event> events = parseResponse.Deserialize<List<Event>>(_responseAsString);
           ViewBag.eventss = events;

html

我如何逐步完成它并创建行或表格谢谢

下面的信息是我的“事件”列表中的许多对象 "[{\"event_key\":\"cc2a1802-2b04-4530-ad50-0d4f0ed19dd3\",\"user_token\":\"40e62a11-40c4-408d- 8cdd-1293cbaf9a41\",\"event_set_key\":\"615017f2-ae28-4b8d-9def-cf043642b928\",\"event_type\":\"到达\",\"event_date\":\"6/20/ 2011 下午 4:15:28\",\"event_amount\":\"100\",\"event_location_key\":\"50fc1c22-d77b-4a91-b31d-da036827060b\",\"event_location_name\":\" Store2\",\"event_location_city\":\"匹兹堡\",\"event_location_state\":\"PA\",\"event_location_country\":\"US\",\"event_location_lat\":\"\" ,\"event_location_long\":\"\",\"event_description\":\"\",\"event_acknowledged\":\"True\"},{\"event_key\":\"2ac9e25e-137c-4a72-8cc5-157d67ea66c1\" ,\"user_token\":\"58cb4fcd-e140-4232-88c9-06eecb95b63d\",\"event_set_key\":\"00710ca7-f5d7-4c7a-bbfb-95491ae278ef\",\"event_type\":\"到达\",\"event_date\":\"9/23/2011 4:15:28 PM\",\"event_amount\":\"45\",\"event_location_key\":\"5a732dd5-9459-4cdd -a980-f3daf1a07343\",\"event_location_name\":\"Store4\",\"event_location_city\":\"匹兹堡\",\"event_location_state\":\"PA\",\"event_location_country\":\ "美国\",\"event_location_lat\":\"\",\"event_location_long\":\"\",\"event_description\":\"\",\"event_acknowledged\":\"False\"},{\"event_key\":\"386b1fa1-11b2-48d9-b7f1- 4bbe21ced487\",\"user_token\":\"c3d8b7ff-d85f-42a8-98f6-e091b48c2280\",\"event_set_key\":\"dc55843b-f8cf-4e8a-9091-188ce0609fe1\",\"event_type\": \"到达\",\"event_date\":\"9/18/2011 4:15:28 PM\",\"event_amount\":\"100\",\"event_location_key\":\"be6d4fb4- c0e3-4303-b70d-7a22b721aa56\",\"event_location_name\":\"Store1\",\"event_location_city\":\"Pittsburgh\",\"event_location_state\":\"PA\",\"event_location_country\ “:\“我们\”,\”event_location_lat\":\"\",\"event_location_long\":\"\",\"event_description\":\"\",\"event_acknowledged\":\"False\"}]"

我已经有一个包含所有元素的类

4

1 回答 1

1

您可以使用以下代码(在 aspx 视图引擎中)。下面的 ViewModel 应该有一个 EventList,它本质上是您的事件集合:

<table id="domainlist" border="0" cellspacing="0" cellpadding="0">
    <thead>
        <tr>
            <th>
                Year
            </th>
             <th>
                Program
            </th>                
            <th>
                Min Score
            </th>           
            <th>
                Max Score
            </th>
             <th>
               Action
            </th>
        </tr>
    </thead>
    <tbody>
    <% foreach (var item in Model.EventList)
       { %>        
        <tr>
            <td>
                <%: item.FiscalYear%>
            </td>
            <td>
                  <%: item.ProgramTypeDescription%>
            </td>               
            <td>
                <%: item.MinScore%>
            </td>           
            <td>
                <%: item.MaxScore%>
            </td> 
            <td>
            <%: Html.ActionLink("View", "ViewProgram", "Program", new { programId = item.Id })%>
            </td>                    
        </tr>        
    <% } %>
    </tbody>
    </table>
于 2012-06-14T21:03:18.613 回答