I tried to do the same thing you are doing when I first was learning asp.net I hated the idea of using <%# %> Let me just say, that using <%# %> in this case is MUCH Easier, than doing it from codebehind!
But to do it in codebehind, in the ItemDataBound event you need something like this (This is an example taken from a datagrid, a repeater should be just about the same)
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
Dim lbl As Label = DirectCast(e.Item.Controls(0).Controls(0), Label)
lbl.text = e.Item.DataItem("Name")
End If
The tricky part which makes this more difficult is finding the right nested sequence of controls that corresponds to the label. And what makes it even more difficult, if you ever change the structure around, you'll need to change this code around.
Hope this helps
--Michael
"Tee" <th*@streamyx.com> wrote in message news:ev**************@TK2MSFTNGP11.phx.gbl...
Hi,
I have a Repeater with a DataReader.
I can successfully let the code run with something like this
<asp:label id="testlabel" text='<%# DataBinder.Eval(Container.DataItem,
"Name") %>' runat="server"></asp:label>
but now I would like to code this few line ItemTemplate in my code-behind
page, how do I do it ?
Thanks,
Tee