在我的控制器中,我的布尔值为isInList。
List<int> listManager = new List<int>() { 123,3231 };
bool isInList = listManager.Contains(newint);
在我看来,仅当bool的值为true时,我才想显示一些数据。 我该怎么做?
@if(@Model.isInList == true)
{
..show this view data...
}
在模型中:
public class IndexHome
{
bool isInList { get; set; }
}
答案 0 :(得分:1)
通常,您要将数据从Controller传递到View
您通过做两件事来做到这一点
return View("SomeViewName", viewModel);
@model myNamsespace.Web.ViewModels.SearchViewModel
完成此操作后,您应该可以在视图内访问@Model.SomeProperty