I'm trying to create an IF conditional inside my aspx page that reads the state of a boolean in the code behind.
Here's the basic ASP:
Expand|Select|Wrap|Line Numbers
- <asp:Repeater ... OnItemDataBound="PrepareRepeater">
- <ItemTemplate>
- // some code
- <#if (variableName == true) {#>
- // code I want to conditionally control
- <#}#>
- </ItemTemplate
- </asp:Repeater>
Expand|Select|Wrap|Line Numbers
- bool variableName; // global
- public void PrepareRepeater() {
- if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
- if (//something) {
- variableName = true;
- } else {
- variableName = false;
- }
- }
- }
Instead it acts like it waits to check the value after all the OnItemDataBound events have ocurred. Maybe this is simple but I can't figure out how to read the value of "variableName" during the OnItemDataBound event.
If anyone can help I'd greatly appreciate it.