我在 C#和 .NET 框架中绝对是新手,我遇到以下问题:
我有一个Web应用程序的视图:
@model DataModel.MaliciousCode.SearchMalicious
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/MasterPageMobile.cshtml";
}
<h2>Index Andrea</h2>
pageSize : @Model.PageSize
@if (Model.TotalRows == 0)
{
<h3>Non è stata trovata nessuna vulnerabilità. Modificare i filtri di ricerca.</h3>
}
else
{
<div style="margin-top: 20px;">
<p>TABELLA</p>
@wGrid.GetHtml(
fillEmptyRows: false,
tableStyle: "MyTable ui-responsive",
headerStyle: "ui-bar-b",
footerStyle: "ui-bar-b",
rowStyle: "ui-bar-a",
alternatingRowStyle: "ui-bar-c",
htmlAttributes: new { data_role = "table", id = "MyWebGrid", data_mode = "reflow" },
columns: new[]{
wGrid.Column ("Title", "Title", canSort : true),
})
@{Html.RenderPartial("Paging", Model);}
</div>
}
我的问题是Visual Studio向我提供了与此视图相关的以下错误消息:
错误2当前名称'wGrid'不存在 context c:\ Develop \ EarlyWarning \ public \ Implementazione \ Ver2 \ WebPortal \ WebPortal \ Views \ Andrea \ Index.cshtml 21 10 WebPortal 错误3当前名称'wGrid'不存在 context c:\ Develop \ EarlyWarning \ public \ Implementazione \ Ver2 \ WebPortal \ WebPortal \ Views \ Andrea \ Index.cshtml 31 21 WebPortal
为什么呢?可能是什么问题呢?我错过了什么?我怎么解决?
答案 0 :(得分:0)
声明我已经完成的WebGrid会工作!用花括号小心!一切顺利!
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/MasterPageMobile.cshtml";
}
<h2>
Index Andrea</h2>
pageSize : @Model.PageSize
@if (Model.TotalRows == 0)
{
<h3>Non è stata trovata nessuna vulnerabilità. Modificare i filtri di ricerca.</h3>
}
else
{
//Declaring the WebGrid
@{ WebGrid wGrid = new WebGrid();
<div style="margin-top: 20px;">
<p>
TABELLA</p>
@wGrid.GetHtml(
fillEmptyRows: false,
tableStyle: "MyTable ui-responsive",
headerStyle: "ui-bar-b",
footerStyle: "ui-bar-b",
rowStyle: "ui-bar-a",
alternatingRowStyle: "ui-bar-c",
htmlAttributes: new { data_role = "table", id = "MyWebGrid", data_mode = "reflow" },
columns: new[]{
wGrid.Column ("Title", "Title", canSort : true),
})
@{Html.RenderPartial("Paging", Model);}
</div>
}
}