Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have worked on a asp.net web form project for an ecommerce website where i have displayed a list of items say electronic products using a REPEATER.

Now i am working on an mvc project but i have no idea how to display these products .
Posted
Updated 25-Aug-16 3:49am
v3

A basic example would be

Controller Action
C#
public ActionResult Index()
{
    var data = //some method to get your data to display
    return View(data);
}


View - Index.cshtml
HTML
@model IEnumerable<your_data_model_or_entity_class_here>

<table>
    <thead>
        <tr>
            <th>Your Column Header Name</th>
        </tr>
    </thead>
    <tbody>
        @foreach(var item in Model)
        {
            <tr>
                <td>
                    <!-- Do something here to display your items in table format (or whatever format you want with as many columns you want -->
                </td>
</tr>
        }
    </tbody>
<table>
</table></table></your_data_model_or_entity_class_here>


But like sitecore said, learning MVC would be best by following tutorials that better explain issues like this more thoroughly than this post does.
 
Share this answer
 
View a Generic List with ASP.NET MVC. Step by Step With Preview 5 - PeterKellner.net[^]

Google "asp.net mvc show list" for other examples. I'd recommend you get a book on MVC and go through it to learn the basics as you can't learn a new technology from forum posts. If you insist on learning this way then google your questions first as there are numerous tutorials out there.
 
Share this answer
 

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