I'm using the Repeater control. All the property names in my data source are represented in my ImportColumns enum.
So I am trying to loop through the enums to pass the names to the Eval method.
This is in ItemTemplate section of my Repeater control.
Line 57: <tr class="ProductRow" data-id="<%# Eval("Id") %>">
Line 58: <% foreach (var column in (ImportColumns[])Enum.GetValues(typeof(ImportColumns))) { %>
Line 59: <td><%# Eval(column.ToString()) %></td>
Line 60: <% } %>
Line 61: </tr>
But line 59 gives me the following error.
CS0103: The name 'column' does not exist in the current context
Why doesn't the code recognize the column variable? I'm guessing it either has something to do with the fact that I'm in a repeater control or that I'm missing <% %> code and <%# %>, but it seems like this should work.
EDIT:
I see that if I change line 59.
<td><%= column.ToString() %></td>
There is no error. (Although it no longer does what I need.)
So this has something to do with Eval that prevents "regular" variables from working. Does anyone know of a workaround to this?
Evalworks on the databound object, but it takes a string argument as the name of the property on that object. I am not changing the object being evaluated. I'm only changing where the string argument comes from. I don't see where I said my edit no longer does what I need.