views:

82

answers:

1

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?

+1  A: 

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

%>
John Boker
It worked but it puts an empty spot for the ones that don't equal blah blah...very close though I think.
Brandon
You are going to have to have something after the else if you don't want the "empty spot". A ternary operator reads like (condition) ? (IfTrue) : (IfFalse). You'll notice in John's example the "IfFalse" return value is just empty string. If you put something else there, you'll be golden.
Anderson Imes
Ahh yes ok. That makes sense! Thanks!
Brandon
Yeah sorry, i should have explained that a little better.
John Boker