Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to create Repeater in MVC4.
Posted
v2

HOpe this help..
Here i had created a strongly typed view and and getting the values from "Model" property

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="manage" id="tblManageUser">
                       <thead>
                           <tr id="0">
                               <th>
                                   Modules name
                               </th>
                               <th>
                                   Modules Decription
                               </th>
                               <th class="center-align">
                                   Edit
                               </th>
                           </tr>
                       </thead>
                       <tbody>
                           @foreach (var item in Model)
                           {
                               <tr id=@item.ModuleId>
                                   <td>
                                       @Html.DisplayFor(modelItem => item.ModuleName)
                                       @Html.Hidden("hdnName" + item.ModuleId, item.ModuleName)
                                   </td>
                                   <td>
                                       @Html.DisplayFor(modelItem => item.ModuleDesc)
                                       @Html.Hidden("hdnDesc" + item.ModuleId, item.ModuleDesc)
                                   </td>
                                   <td align="center">
                                       <a href="javascript:();"  rel="edit-Source" onclick="EditMenu(@item.ModuleId)"  id=@item.ModuleId>
                                           <i class="icon-edit"></i></a>
                                   </td>
                               </tr>

                           }</tbody>
                   </table>
 
Share this answer
 
HTML
@foreach (var item in Model)
                            {  
                                <tr id="@item.ModuleId">
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ModuleName)
                                        @Html.Hidden("hdnName" + item.ModuleId, item.ModuleName)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.ModuleDesc)
                                        @Html.Hidden("hdnDesc" + item.ModuleId, item.ModuleDesc)
                                    </td>
                                    <td align="center">
                                        <a href="javascript:();" rel="edit-Source" onclick="EditMenu(@item.ModuleId)" id="@item.ModuleId">
                                            </a>
                                    </td>
                                </tr>
                          
                            }
 
Share this answer
 
Comments
CHill60 17-Jun-14 12:53pm    
Any particular reason why you copied this from Solution 1 (minus the icon-edit)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900