Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何在razor视图中检查字符串值?_Asp.net Mvc_String_View - Fatal编程技术网

Asp.net mvc 如何在razor视图中检查字符串值?

Asp.net mvc 如何在razor视图中检查字符串值?,asp.net-mvc,string,view,Asp.net Mvc,String,View,我有一个模型,我想显示圆顶数据,如果table\u name==“something”。所有数据都不同,这就是我需要检查的原因。但是当我写==时,我的观点不明白。它只返回else子句数据。 请帮助我,如何检查视图中的字符串值 @foreach (var item in Model) { if (item.table_name == "tPerson") { <a href="#" class="list-group-item"&

我有一个模型,我想显示圆顶数据,如果
table\u name==“something”
。所有数据都不同,这就是我需要检查的原因。但是当我写
==
时,我的观点不明白。它只返回
else
子句数据。 请帮助我,如何检查视图中的字符串值

@foreach (var item in Model)
{                       
    if (item.table_name == "tPerson")
    { <a href="#" class="list-group-item">@item.user_group_name: <strong>@item.user_full_name</strong> | @item.date</a>;
    }
    else if (item.table_name == "tBook")
    { <a href="#" class="list-group-item">Book<strong>@item.book_name</strong> | @item.date</a>}
    else
    {<a href="#" class="list-group-item">@item.table_name  <strong>@item.name</strong> | @item.date</a>}

}
@foreach(模型中的变量项)
{                       
如果(item.table_name==“tPerson”)
{ ;
}
else if(item.table_name==“tBook”)
{ }
其他的
{}
}

查看“item.table\u name”的后空格或前空格

您应该使用强类型视图。
table\u name的类型是什么
当它与“tPerson”和“tBook”不匹配时,它的值是什么?伙计们,当我添加item.table\u name.TRIM()