Добрый день, я пытаюсь сделать форму для редактирования данных. Нашла обучающий урок:
Код | http://ricardocovo.com/2011/04/03/asp-mvc3-editing-records-with-jqueryui-dialogs-and-ajaxforms/
|
В этом уроке создается сначала лист с данными:
Код | using System; using System.Collections.Generic; using System.Linq; using System.Web; using MvcApplication1.Models; namespace MvcApplication1.Data
{ public static class CarRepository { static List<CarModel> CarList;
static CarRepository() { CarList = new List<CarModel>{ new CarModel { Id=1, ImageFileName="FordFocusElectric.jpg", Name="Ford Focus Electric", Description = "Great looking car... plus is green."}, new CarModel { Id=2, ImageFileName="HondaCivic2012.jpg", Name="Honda Civic 2012", Description="You can always count with the Civic"}, new CarModel { Id=3, ImageFileName="HyundaiHCD12.jpg", Name="Hyundai HCD 12", Description="Can't wait for it to come out!"}, new CarModel { Id=4, ImageFileName="ToyotaPriusC.jpg", Name="Toyota Prius C", Description="What does the C stands for?"}}; }
/// <summary> /// NOTE: This is for demostration purposes only. /// You would normally have your data access layer, either on the web app or in other libraries. /// </summary> /// <returns></returns> public static List<CarModel> GetCars() { return CarList; } } }
|
а затем отображается этот CarList на страницу :
Код | <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2> <div id="commonMessage"></div> <table> <% foreach (var item in Model) { %> <tr> <td> <img src="/content/images/<%: item.ImageFileName %>" /> </td> <td> <strong><span class="carName"><%: item.Name %></span></strong><br /> <span class="carDescription"><%: item.Description %></span><br /><br /> <%: Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "editLink" })%> </td> </tr> <% } %>
</table>
|
Меня интересует как мне вывести на страницу не весь CarList, а только конкретный елемент, например я хочу вывести информацию только для Toyota Prius C ?
Спасибо.
|