J
Jonathan Wood
I have a Web form with a ListView control and, since my formatting is a
little involved, I would like to perform that formatting from code. To this
end, I changed my ItemTemplate from this:
<tr runat="server">
<td>
<%#Eval("Name")%>
</td>
</tr>
to this:
<tr runat="server">
<td>
<%#FormatName(Container)%>
</td>
</tr>
And I wrote a FormatName() method that returns a string. This worked okay
but it occurs to me that it would be quite a bit more efficient if, instead
of building and returning a string, if my method simply emitted the text
directly using Response.Write().
In this case, I need to call my method but not display the result. So I
tried changing my ItemTemplate to:
<tr runat="server">
<td>
<% FormatName(Container); %>
</td>
</tr>
But now I get the error that Container is not available in the current
context.
Is there any way to access the current ListViewDataItem this way?
Thanks.
Jonathan
little involved, I would like to perform that formatting from code. To this
end, I changed my ItemTemplate from this:
<tr runat="server">
<td>
<%#Eval("Name")%>
</td>
</tr>
to this:
<tr runat="server">
<td>
<%#FormatName(Container)%>
</td>
</tr>
And I wrote a FormatName() method that returns a string. This worked okay
but it occurs to me that it would be quite a bit more efficient if, instead
of building and returning a string, if my method simply emitted the text
directly using Response.Write().
In this case, I need to call my method but not display the result. So I
tried changing my ItemTemplate to:
<tr runat="server">
<td>
<% FormatName(Container); %>
</td>
</tr>
But now I get the error that Container is not available in the current
context.
Is there any way to access the current ListViewDataItem this way?
Thanks.
Jonathan