开发者

creating data templates using MVC and asp.net

I am currently evaluating the use of asp.net and MVC for a new project (vs. web part or web form pattern). While I really like the MVC pattern and the ability开发者_开发百科 to abstract the code from the UI. I have a specific requiremt to create a custom control that returns data in a pre-defined format. As an example for this project I need to have data returned in a listbox control where there listboxt items contain an image and then values from the DAL. I want to have control over where the image and values from the DAL appear in the listbox control. Using WPF I have done this using Data templates. Is this possible using ASP.NET and the MVC pattern or is this only possible using a web form/ web part pattern? Any links examples or refernces would be greatly appreciated. Thanks in advance!

Update In doing some more reading it appears that I can control how the data would be rendered in the view using markup: As an example if I have a collection (products) that returns image, name, description, price I can render this in the view by writing:

<ul id="products">
    <% foreach (var p in products)
       { %>
    <li>
        <%:p.image%>
        <%:p.name%>
        <br />
        <%:p.description%>
        <%:p.price%>
    </li>
    <%} %>
</ul>

My question is this the correct approach or am I headed down the wrong path?


You could use some jQuery plugin which would allow you to create nice dropdown lists with images.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜