HaB*_*aBo 6 grid conditional telerik
如何在MVC Telerik Grid Control中完成这项工作
columns.Template(e =>
{
if (e.EndDate>DateTime.Now )
{
@Html.ActionLink("Stop", "StopMedication", "Medication",
new { id = e.PrescriptionID }, new { @class = "standard button" })
}
else {
@Html.ActionLink("Renew", "RenewMedication", "Medication",
new { id = e.PrescriptionID }, new { @class = "standard button" })
}
});
Run Code Online (Sandbox Code Playgroud)
小智 11
以下代码段应该使用Razor语法在Telerik网格模板列中完美运行:
columns.Template(
@<text>
@if (@item.EndDate > DateTime.Now)
{
@Html.ActionLink("Stop", "StopMedication", "Medication",
new { id = @item.PrescriptionID }, new { @class = "standard button" })
}
else
{
@Html.ActionLink("Renew", "RenewMedication", "Medication",
new { id = @item.PrescriptionID }, new { @class = "standard button" })
}
</text>
);
Run Code Online (Sandbox Code Playgroud)
利用@<text></text>模板内部,以及使用代表当前项(与行绑定的实体)及其属性的@item对象,将允许您启动并运行此模板.