我有一个返回字符串列表的方法.我只是想在视图中以纯文本形式显示该列表.
这是控制器的列表:
public class ServiceController : Controller
{
public string Service()
{
//Some code..........
List<string> Dates = new List<string>();
foreach (var row in d.Rows)
{
Dates.Add(row[0]);
}
return Dates.ToString();
}
public ActionResult Service()
{
Service();
}
}
Run Code Online (Sandbox Code Playgroud)
并且观点:
<table class="adminContent">
<tr>
<td>HEJ</td>
</tr>
<tr>
<td>@Html.Action("Service", "Service")</td>
</tr>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我认为我必须在视图中做一些像foreach循环一样的东西并使用"@"引用列表但是如何?
我有两个不同的列表geocode1和geocode2都有5行记录. geocode1有4列,即地址,城市,邮编和街道. geocode2有4列,即latitute,经度,Status和County
使用addrange合并它们,如下所示:
geocode1.Addrange.(geocode2)
Run Code Online (Sandbox Code Playgroud)
导致geocode1有8列(这是我想要的)但是有10行,前五个包含第一个列表中的值(geocode1),最后五个包含来自第二个列(geocode2)的值.(比如SQL中的外连接)
我希望有8列但是5行,两个列表的元素组合在一起就像SQL中的内连接一样.任何人都可以为我提供解决方案吗?