I have a grid column with checkboxes and I want to give them a different id. Id is based on the CustomerId in the Model. What syntax should I use to concatenate the chk_@item.CustomerId.
我有一个带有复选框的网格列,我想给它们一个不同的ID。 Id基于模型中的CustomerId。我应该使用什么语法来连接chk_@item.CustomerId。
// using the telerik grid
id="chk_@item.OrderNumber" // does not work
// this will put the value of @item.Customernumber as the checkbox id
//这会将@ item.Customernumber的值作为复选框ID
columns.Template(@<text><input type='checkbox' id="@item.Customernumber" name="@item.CustomerNumber" value="@item.OrderNumber" /></text>).Width(50)
second option:
第二种选择:
columns.Template(@<text><input type='checkbox' id="chk_@item.Customernumber" name="@item.CustomerNumber" value="@item.OrderNumber" /></text>).Width(50)
the above will render as
以上将呈现为
<input type="checkbox" id="chk_@item.Customernumber" value=... />
2 个解决方案
#1
40
chk_@item.OrderNumber
will not work because razor thinks of it as of an e-mail, you need to do it like this instead: chk_@(item.OrderNumber)
chk_@item.OrderNumber不起作用,因为razor认为它是电子邮件,你需要这样做:chk _ @(item.OrderNumber)
#2
22
Correct Syntax
正确的语法
id="@("chk_"+@item.Id)"
#1
40
chk_@item.OrderNumber
will not work because razor thinks of it as of an e-mail, you need to do it like this instead: chk_@(item.OrderNumber)
chk_@item.OrderNumber不起作用,因为razor认为它是电子邮件,你需要这样做:chk _ @(item.OrderNumber)
#2
22
Correct Syntax
正确的语法
id="@("chk_"+@item.Id)"