简体   繁体   中英

(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") : ""

%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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