简体   繁体   English

(C#)有条件在前端使用datagrid

[英](C#) conditional in front end with datagrid

I have a data grid and in that grid its making this call: 我有一个数据网格,并在该网格中进行此调用:

<ItemTemplate>                                      
<%#GroupSelectorRoleListControlExtender.GenerateGroupActuator(((GroupListItem)Container.DataItem).Id, ((GroupListItem)Container.DataItem).Name)%>
</ItemTemplate>

I would like to do something like this: 我想做这样的事情:

<% if (((SingleAccountGroup)Container.DataItem).Name == "blahblah") {%>
<ItemTemplate>
<%#GroupSelectorRoleListControlExtender.GenerateGroupActuator(((SingleAccountGroup)Container.DataItem).Id, ((SingleAccountGroup)Container.DataItem).Name, "portalprofile Name")%>
</ItemTemplate>
<%} %>

It of course doesn't work but hopefully you can see what I'm trying to do, it doesn't like that it's not bound. 它当然不起作用,但希望您能看到我正在尝试做的事情,它不喜欢它没有约束。 How can I put that conditional into a data grid like that? 我该如何将这种条件放入这样的数据网格中?

you might be able to use a ternary operator to make it work 您可能可以使用三元运算符来使其工作

<%#

((SingleAccountGroup)Container.DataItem).Name == "blahblah" ? 
GroupSelectorRoleListControlExtender.GenerateGroupActuator(((SingleAccountGroup)Container.DataItem).Id, ((SingleAccountGroup)Container.DataItem).Name, "portalprofile Name") : ""

%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM