[英]Asp.net MVC Razor @foreach + onclick the data gets listet
I'm working on a Project Tool that lists all the Projects on the Dashboard.我正在开发一个项目工具,它列出了仪表板上的所有项目。 Now I want that when I click on the Project that the Data from my Database gets listed on the right site of it.
现在我希望当我单击项目时,我的数据库中的数据会列在它的正确站点上。
Problem 1问题一
Code:代码:
@foreach (var item in Model)
{
<tbody>
<tr>
<td>Project Titel</td>
<td>@item.PrjTitel</td>
</tr>
</tbody>
}
With this all the Database Data gets listet, but i just want the Data from one Project not from Project 1,2,3 listet.有了这个,所有的数据库数据都得到了列表,但我只想要来自一个项目的数据而不是来自项目 1、2、3 的列表。
How can i make that ?我怎样才能做到?
Problem 2问题二
How can i make that the Data gets listet when the User clicks on a Project.当用户点击一个项目时,我怎样才能让数据得到列表。 So if i click on Project 2 the data from Project to gets listet on the right site.
因此,如果我单击项目 2,项目中的数据将在正确的站点上获取列表。 See Screenshot -->
见截图-->
@foreach (var item in Model.Projects) {
<tbody>
<tr>
<td>@Ajax.ActionLink("Select","SelectProjects",new { @id=item.ProjectId},new AjaxOptions { HttpMethod="GET",OnSuccess="LoadProjectsSuccess", OnFailure="LoadProjectsFailur",InsertionMode=InsertionMode.Replace,UpdateTargetId= "Projects" },new { @class="btn btn-info btn-table"})</td>
</tr>
</tbody>}
<div class="row row-equal" id="Privileges"><div>
you can use AjaxHelper if you don't have any information about ajax helper please visit Ajax Helper如果您没有任何关于 ajax helper 的信息,您可以使用 AjaxHelper,请访问Ajax Helper
public ActionResult SelectProjects(int id)
{
DemoViewModel model = new DemoViewModel()
{
// Your ViewModel
};
return PartialView("_ProjectDetails", model);
}
_ProjectDetails Partial View with data you wont to update _ProjectDetails 部分视图,其中包含您不会更新的数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.