我创建了一个视图索引并在该视图上我在该视图上放置了一个共享视图,但现在我必须从该共享视图调用控制器操作(_TraningList)
这是索引视图
为此,我做了以下事情
@Html.Partial("~/Views/Shared/_TrainingList.cshtml", Model.First().Categories)
@Html.Partial("_ConsultingList")
@Html.Partial("_UpcomingWebinarList")
这是共享视图
@model IEnumerable<QPS_MVC.BusinessLogic.CourseCategories>
<!--Training Box-->
<div class="bodyContentWrp">
@*@Html.Action("Index", "Trainings")*@
<h1>
Training Programs</h1>
@* <ul class="arw1">
<li>Aerospace</li>
<li>Agile</li>
<li>APICS/SME Certifications</li>
<li>ASQ Certifications</li>
<li>FDA Related</li>
<li>HR Related</li>
<li>ISO Related</li>
<li>IT Certifications</li>
<li>Lean Six Sigma</li>
<li>PMI Certifications</li>
</ul>
*@
@foreach (QPS_MVC.BusinessLogic.CourseCategories item in Model)
{
<ul>
<li>@Html.ActionLink(item.Name, "", "Trainings", new { SelectedId = item.CategoryID }, null)</li>
<li></li>
</ul>
}
<div class="clear">
</div>
<div class="readMore">
<a href="#">Read More</a></div>
<div class="clear">
</div>
这是控制器
public ActionResult Index()
{
List<Courses> obj = new List<Courses>();
if (Request.QueryString.Count > 0 && Request.QueryString["SelectedId"] != null && !string.IsNullOrEmpty(Request.QueryString["SelectedId"].ToString()))
{
obj = new CoursesApp().getAllCoursesById(int.Parse(Request.QueryString["SelectedId"].ToString()));
}
else
{
obj = new CoursesApp().getAllCourses();
obj = new CoursesApp().getAllCoursesById(obj.First().Categories.First().CategoryID);
}
//if (ViewData["CategoryId"] == null || string.IsNullOrEmpty(ViewData["CategoryId"].ToString()))
//{
// obj = new CoursesApp().getAllCourses();
// obj = new CoursesApp().getAllCoursesById(obj.First().Categories.First().CategoryID);
//}
//else
//{
// obj = new CoursesApp().getAllCoursesById(int.Parse(ViewData["CategoryId"].ToString()));
//}
return View(obj);
}
所以基本上我想从 Shared View _trainingList 调用这个索引操作,我已经完成了上述操作,但我无法成功,所以请任何人帮助我。