我正在关注来自here的kendoUI详细信息模板示例,如果您在链接下方,您会看到一些类似“#= Country#”的内容来显示该国家/地区。如果在检查中如何在剃刀中获取此值,当我通过注释if检查并使用@GetServerID来显示值来运行代码时,我得到它的值但是如何在“if”中使用它。这似乎是一个非常愚蠢的问题,但我需要一些帮助才能弄明白。 请注意,除非其他所有内容都正常工作,否则我需要编码值“#= ...#”。
@using ServerList.Model.Model
@{
var viewDataServer = (List<ServerDetails>)ViewData["TestData"];
ViewBag.Title = "Environment";
Session["Index"] = (Convert.ToInt16(Session["Index"]) + 1);
int x = 0;
}
<h2>@ViewBag.Title</h2>
@(Html.Kendo().Grid<EnvironmentPOCO>()
.Name("Grid")
.Columns(columns =>
{
//columns.Bound(d => d.EnvironmentID).Visible(false);
columns.Bound(d => d.EnvironmentName).Width(200).Title("Environment Name").Visible(false);
columns.ForeignKey(d => d.EnvironmentTypeID, (List<EnvironmentTypePOCO>)ViewData["EnvironmentType"], "EnvironmentTypeID", "EnvironmentTypeCode").Width(150).Title("Environment Code").EditorTemplateName("_EnvironmentCodeDropDown");
columns.ForeignKey(d => d.ServerID, (List<ServerPOCO>)ViewData["MyServers"], "ServerID", "ServerDetailsProperty").Width(300).Title("Server Details").EditorTemplateName("_ServerDropDown");
columns.ForeignKey(d => d.ProjectID, (List<ProjectPOCO>)ViewData["MyProjects"], "ProjectID", "ProjectDetailsProperty").Width(400).Title("Project Details").EditorTemplateName("_ProjectNameDropDown");
columns.Command(d =>
{
d.Edit();
d.Destroy();
}).Width(200).Title("Action");
}
)
.ToolBar(tools => tools.Create())
.Sortable()
.Pageable()
.Filterable()
.Navigatable()
.Sortable(sortable => sortable.AllowUnsort(false))
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.Events(events => events.Change("GetServerID"))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(m => m.EnvironmentID);
})
.Read(read => read.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Get))
.Create(create => create.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Post))
.Update(update => update.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Put))
.Destroy(destroy => destroy.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Delete))
)
)
这是TabStripCode
items.Add().Text("Contact Information").Content(@<div>
<ul>
@foreach(var Login in viewDataServer)
{
var GetServerID="#=ServerID#";
if("#=ServerID#"==Login.ServerID.ToString())
{
@GetServerID
<li><label>UserID:</label>@Login.UserID.ToString()</li>
<li><label>Password:</label>@Login.passwd.ToString()</li>
}
}
</ul>
</div>);
})