如何通过选定的样本获取示例详细信息?
例如,我需要获取示例详细信息取决于选定的样本 单击示例1的详细信息显示其详细信息和样本2,依此类推 我混淆了如何做到这一点,我在MVC中是新手:
这是控制器代码:
public ActionResult Index()
{
int UserId = Convert.ToInt32(Session["UserID"]);
var samples = _context.hospital_programs.Where(x => x.hospital_id == UserId).ToList();
return View(samples);
}
这是图像ID示例名称中的输出图像列:
这是视图代码:
<table class="table">
<tr>
<th>
</th>
<th>
@Html.DisplayNameFor(model => model.Program.name)
</th>
<th>
@Html.DisplayNameFor(model => model.sample.id)
</th>
<th>
@Html.DisplayNameFor(model => model.sample.name)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.sample.id)
</td>
<td>
@Html.DisplayFor(modelItem => item.sample.name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.id }) |
@Html.ActionLink("Details", "Details", new { id=item.id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.id })
</td>
</tr>
}
</table>
这是详细信息控制器代码:
public ActionResult Details(int id )
{
int UserId = Convert.ToInt32(Session["UserID"]);
var results = _context.RESULTS.Where(r => r.custid == UserId).ToList();
return View(results);
}
现在在详细信息中,当我单击示例的详细信息1时,它显示了所有样本的结果 如何更新代码以仅查看示例1结果或样本2结果仅
在我要添加samemid =选定样品的地方?
I need to get sample details depends on selected sample for example
when click on details of sample 1 show its details and sample 2 and so on
I confused how to do that I am new in MVC :
This is the controller code :
public ActionResult Index()
{
int UserId = Convert.ToInt32(Session["UserID"]);
var samples = _context.hospital_programs.Where(x => x.hospital_id == UserId).ToList();
return View(samples);
}
this is the output image columns in image Id Sample Name:
this is the view code :
<table class="table">
<tr>
<th>
</th>
<th>
@Html.DisplayNameFor(model => model.Program.name)
</th>
<th>
@Html.DisplayNameFor(model => model.sample.id)
</th>
<th>
@Html.DisplayNameFor(model => model.sample.name)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
</td>
<td>
@Html.DisplayFor(modelItem => item.Program.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.sample.id)
</td>
<td>
@Html.DisplayFor(modelItem => item.sample.name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.id }) |
@Html.ActionLink("Details", "Details", new { id=item.id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.id })
</td>
</tr>
}
</table>
This is the details controller code :
public ActionResult Details(int id )
{
int UserId = Convert.ToInt32(Session["UserID"]);
var results = _context.RESULTS.Where(r => r.custid == UserId).ToList();
return View(results);
}
In the details now when I click details for sample 1 it shows results for all samples
how can I update the code to view only sample 1 results or sample 2 results only
where I will add sampleId = selected sample ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案:
用sample_id替换ID
I found the solution :
replace id with sample_id