This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="hidden" name="list.Index" value="0" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public ActionResult PostData(List<ItemModel> list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="hidden" name="list.Index" value="0" /> | |
<input type="text" name="list[0].Name" value="Alex" /> | |
<input type="text" name="list[0].Description" value="..." /> | |
<input type="hidden" name="list.Index" value="1" /> | |
<input type="text" name="list[1].Name" value="Chris" /> | |
<input type="text" name="list[1].Description" value="..." /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using (Html.BeginForm("PostData", "Home", FormMethod.Post, new { id = "simpleForm" })) | |
{ | |
ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "list[0]"; | |
<input type="hidden" name="list.Index" value="0" /> | |
@Html.TextBoxFor(x => x.Name) | |
@Html.TextBoxFor(x => x.Description) | |
ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "list[1]"; | |
<input type="hidden" name="list.Index" value="1" /> | |
@Html.TextBoxFor(x => x.Name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using (Html.BeginForm("PostData", "Home", FormMethod.Post, new { id = "simpleForm" })) | |
{ | |
@(Html.Grid(Model.Items) | |
.RenderUsing(new PostAsListRenderer<ItemModel>("list")) | |
.Columns(c => | |
{ | |
c.For(x => Html.Partial("Grid/Id", x)).Named("Id"); | |
c.For(x => Html.Partial("Grid/Name", x)).Named("Name"); | |
c.For(x => Html.Partial("Grid/Description", x)).Named("Description"); | |
c.For(x => Html.Partial("Grid/SelectedItem", new ListModel { SelectedItem = x.SelectedItem, SelectListItems = Model.SelectListItems })).Named("DropDown"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using (Html.BeginForm("PostData", "Home", FormMethod.Post)) | |
{ | |
@(Html.Grid(Model.Items) | |
.RenderUsing(new PostAsListRenderer<ItemModel>("list")) | |
.Columns(c => | |
{ | |
c.Custom( | |
@<text> | |
@Html.HiddenFor(x => item.Id) | |
@item.Id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PostAsListRenderer<T> : HtmlTableGridRenderer<T> where T : class | |
{ | |
private readonly string _collectionName; | |
private string _previousHtmlFieldPrefix; | |
Guid _currentIndex; | |
bool _firstCellRendered; | |
public PostAsListRenderer(string collectionName) | |
{ | |
_collectionName = collectionName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContractListBuilder IViewBuilder<int, List<SelectListItem>> | |
class LanguageListBuilder IViewBuilder<int, List<SelectListItem>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Data.Entity; | |
using System.Linq; | |
using AutoMapper; | |
namespace EFTests | |
{ | |
public class Program | |
{ | |
public static void Main() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewModel : InputModel | |
{ | |
public bool ShowSaveButton { get; set; } | |
public string Customer { get; set; } | |
} |