Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将actionLink提交到表单mvc4_C#_Asp.net Mvc_Asp.net Mvc 4 - Fatal编程技术网

C# 将actionLink提交到表单mvc4

C# 将actionLink提交到表单mvc4,c#,asp.net-mvc,asp.net-mvc-4,C#,Asp.net Mvc,Asp.net Mvc 4,我们有一个行动链接列表 局部视图 @foreach (var item in Model.Regions) { <tr> <td> @Html.DisplayFor(modelItem => item.RegionName) </td> <td> <input type="submit" value="Select" /> </td>

我们有一个行动链接列表

局部视图

@foreach (var item in Model.Regions) {
    <tr>

    <td>
        @Html.DisplayFor(modelItem => item.RegionName)
    </td>

    <td>
        <input type="submit" value="Select" />
    </td>

     @Html.HiddenFor(modelItem => Model.Id)
</tr>
}
</table>

感谢您抽出时间

下面是我传递模型实例的示例。我有一个包含许多课程的视图,所以我需要单击一个按钮并启动一个操作,从而携带所单击课程的所有数据(包括相关ID)。因此,最后,我用隐藏字段携带了我需要的实例。:)

我的课程模型

public class CourseModel
    {
        public int RecordId { get; set; }
        public string StudentNameField { get; set; }
        public string SubjectField { get; set; }
        public string CatalogField { get; set; }
        public string SectionField { get; set; }
        public string InstrNameField { get; set; }
        public string MtgStartField { get; set; }
        public string MtgEndField { get; set; }

    }
我的主视图…在视图文件夹中称为“课程列表”

<div id="container">          
<div class="selectLabel">Select a Course:</div><br />
 @foreach (var item in Model)
{           
    @Html.DisplayFor(model=>item)
}
</div>          

model.RegionName=\u facade.FetchRegion(model.RegionId).RegionName此行不起作用?
public class CourseModel
    {
        public int RecordId { get; set; }
        public string StudentNameField { get; set; }
        public string SubjectField { get; set; }
        public string CatalogField { get; set; }
        public string SectionField { get; set; }
        public string InstrNameField { get; set; }
        public string MtgStartField { get; set; }
        public string MtgEndField { get; set; }

    }
<div id="container">          
<div class="selectLabel">Select a Course:</div><br />
 @foreach (var item in Model)
{           
    @Html.DisplayFor(model=>item)
}
</div>          
@using LecExamRes.Helpers
@model LecExamRes.Models.SelectionModel.CourseModel
@using (Html.BeginForm("CourseList", "Home", null, FormMethod.Post))
{
<div class="mlink">
    @Html.AntiForgeryToken()
    @Html.EncryptedHiddenFor(model => model.RecordId)
    @Html.EncryptedHiddenFor(model => model.CatalogField)
    @Html.EncryptedHiddenFor(model => model.SectionField)
    @Html.EncryptedHiddenFor(model => model.SubjectField)
    @Html.EncryptedHiddenFor(model => model.InstrNameField)
    @Html.EncryptedHiddenFor(model => model.MtgStartField)
    @Html.EncryptedHiddenFor(model => model.MtgEndField)
    <p>
        <input type="submit" name="gbtn" class="groovybutton"      value="@Model.SubjectField - @Model.CatalogField - @Model.SectionField : @Model.InstrNameField">
    </p>  
 </div>
}
  [ValidateAntiForgeryToken]
    [HttpPost]
    public ActionResult CourseList(SelectionModel.CourseModel model)
    {
        //....do something with my model
       }