I am trying to create a repeater programmatically and am having trouble figureing out how to put the Eval("column name") code into the template.
I saw some code that said to use Databinder.Eval(Container.DataItem, "columnname"), but when I do Container. DataItem is not available in the object. I tried renaming the container to cont in the instantiate in sub but that didnt make the other container object available.
Here is the original code done the normal way.
Here is the code I have so farCode:<asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <div> <strong>Q.</strong><a style="margin-left: 10px;" href='javascript:toggleDiv(<%#Eval("ItemID") %>)'><%#Eval("Question")%></a><br /> <div id='<%#Eval("ItemID") %>' class="Answers"><%#Eval("Answer")%></div> </div> </ItemTemplate> </asp:Repeater>
Code:Dim faqRepeat As New Repeater Protected sub page_init(byval...., ...) handles me.init faqRepeat.ItemTemplate = New MyTemplate end sub Public Class MyTemplate Implements ITemplate Sub InstantiateIn(ByVal container As Control) _ Implements ITemplate.InstantiateIn Dim str As String = "" str = "<strong>Q.</strong>style='margin-left: 10px;' href='javascript:toggleDiv(" End Sub End Class


Reply With Quote

Anything that you put in there becomes 'source code' to be generated as HTML to the user's browser, there is no second-pass execution.
