how to display records as popular products in MVC5


when i search in google  to display records as popular products in grid like (shopping website displays products in grid ), web grid uses to show records<– in web form we will use gridview. whcih is okay.

I want to display few information about products in front-end like follow

for example.

column1                                        column2                          column3

price of product                          price of product                  price of product

descript of product                     descript of product             descript of product  

image of descript                        image of descript                 image of descript

and etc                                        and etc                                  and etc 

if it is web form. i will use either datalist or list view for that.

So, how to achieve in  MVC5. what control i should use. i am new for mvc5. can you help how to solve this problem?


I recommend looking at the WebGrid, which renders a table similar to the GridView in Web Forms:

Or you could just use HTML to render a list, or divs or similar:

@foreach(var item in Model){
    <div style="box">
    @item.Price<br />
    @item.Description<br />
    <img src="@item.Image" />

Style for the div:

    display: inline-block;
    vertical-align: top;
    width: 200px;

Thank you for reply. the one you explained i understood. But, it will display one column. 

as you know if you use datalist , according to repeat column it will display. like follow.

<div id="divProducts">
<asp:DataList ID="dlstProducts" runat="server" RepeatColumns="3" CellSpacing="10"
RepeatDirection="Horizontal" RepeatLayout="Table">
<div class="item">
<span><strong><%# Eval("Name") %></span></strong><br />
<span><%# Eval("Description") %></span><br />
<span>$<%# Eval("Price")%></span>

same concept if we use list view. how can i achieve this?

Leave a Reply