我正在使用ExcelReader上传新的包含数据并从DbSet获取所有旧数据。我正在使用Entity Framework POCO方式来POST / GET数据。我想对POST / GET使用相同的视图。我有两个提交按钮一个用于保存当前数据,另一个用于从datacontext获取所有数据。现在我的查看代码低于我,我按照包括here的步骤进行操作! 我收到以下错误“System.Reflection.AmbiguousMatchException”。我猜这是因为HTNL.Beginfrom()因为动作结果名称而创建它。 如果我需要使用@ Html.AntiForgeryToken(),任何人都可以帮助我解决这个问题吗? @ Html.ValidationSummary();在我的GET / POST电话中。
[MultipleButton(Name = "action", Argument = "Index")]
public ActionResult Index(HttpPostedFileBase uploadfile,dataViewModel dataView1)
{
// code for upload
}
[MultipleButton(Name = "action", Argument = "ExcelData")]
public ActionResult ExcelData()
{
ReadContext Context = new ReadContext();
return View(Context.dataext.ToList());
}
我的观看代码:
@{
ViewBag.Title = "Read Excel File and Display in mvc5";
}
@model System.Data.DataTable
@using System.Data
<h2>Read Excel File and Display in mvc5</h2>
@using (Html.BeginForm("Index", "ReadExcel", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken();
@Html.ValidationSummary();
<label class="text-info">Upload Excel File</label>
<input type="file" class="form-control" name="uploadfile" id="uploadfile" />
<input type="submit" value="submit" class="btn btn-default" name="action:Index" />
<input type="submit" value="data" class="btn btn-default" name="action:ExcelData" />
if (Model != null)
{
<table class="table table-responsive table-bordered">
<thead>
<tr>
@foreach(DataColumn column in Model.Columns)
{
<th>@column.ColumnName</th>
}
</tr>
</thead>
<tbody>
@foreach(DataRow row in Model.Rows)
{
<tr>
@foreach(DataColumn col in Model.Columns)
{
<td>@row[col.ColumnName]</td>
}
</tr>
}
</tbody>
</table>
}
}