我是Asp.net的新手,遇到了问题,这是我的代码: 这是我的表格:
我想将表单的SectionName字段作为参数传递给Controller的方法。
<div class="row">
<div class="col-sm-3">
@Html.LabelFor(m => m.SectionName)
@Html.DropDownListFor(model => model.SectionName, new SelectList(" "), "--Select Section--", new { @class = "form-control" })
</div>
<div class="col-sm-3">
<div class="editor-lable">@Html.LabelFor(m => m.Date)</div>
<div class="editor-field">@Html.EditorFor(m => m.Date)</div>
</div>
@*<div class="col-sm-3">
<div class="editor-lable">@Html.LabelFor(m => m.AllPresent)</div>
<div class="checkbox">@Html.EditorFor(m => m.AllPresent)</div>
</div>*@
<div class="row">
<div class="col-md-10">
<input type="submit" id="onClick" value="Submit" class="btn btn-primary" />
</div>
</div>
@foreach (var item in Attendances)
{
@Ajax.ActionLink(item.SectionName, "AttendanceDetail", "Faculty", new { sectionName = Model.SectionName },
new AjaxOptions() { UpdateTargetId = "p1" })
}
</div>
这是我的控制器方法:
[HttpGet]
public ActionResult AttendanceDetail(GetStudentAttendance_Result model, string sectionName)
{
GetStudentAttendance_Result at = new GetStudentAttendance_Result() {
AttendanceDetail = model.AttendanceDetail,
Name = model.Name,
RollNo = model.RollNo,
Present = model.Present,
StudentId = model.StudentId,
AttendanceId = model.AttendanceId
};
if (sectionName == null) {
return View(at);
} else {
var atten = Db.GetStudentAttendance(sectionName);
return PartialView("AttendanceDetail", atten);
}
}
请帮我这样做! 谢谢!