-
-
Save doggy8088/58dd3c773ef9877155b19ebb2fda8525 to your computer and use it in GitHub Desktop.
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.Collections.Generic; | |
using System.Web.Mvc; | |
using WebApplication1.Models; | |
namespace WebApplication1.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
var data = new List<Person>(); | |
data.Add(new Person() { Id = 1, Name = "Will" }); | |
data.Add(new Person() { Id = 2, Name = "Tom" }); | |
data.Add(new Person() { Id = 3, Name = "Mary" }); | |
return PartialView(data); | |
} | |
} | |
} |
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
namespace WebApplication1.Models | |
{ | |
public class Person | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} | |
} |
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 WebApplication1.Models | |
@model IEnumerable<Person> | |
<html> | |
<body> | |
<p> | |
Field name of the first record:@Html.NameFor(m => m.First().Name)<br /> | |
</p> | |
@{ | |
var data = Model.ToArray(); | |
} | |
@using (Html.BeginForm()) | |
{ | |
<ol> | |
@for (var i = 0; i < data.Length; ++i) | |
{ | |
<li> | |
@Html.DisplayNameFor(m => m.Name): | |
@Html.TextBoxFor(m => data[i].Name) | |
( Field Name: @Html.NameFor(m => data[i].Name) ) | |
</li> | |
} | |
</ol> | |
} | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment