c# - ASP:Literal not within context when placed in ItemTemplate of Repeater -
i have asp.net page behaving differently peers , can't seem find out why.
sadly cannot post lot of code business reasons, , know limit users' ability assist.
i have 1 page have hidden , checkbox , other unimportant things.
something like:
<asp:repeater id="goodrepeater" runat="server" onitemdatabound="goodrepeater_onitemdatabound"> <itemtemplate> <asp:literal id="lithappyliteral" runat="server" /> <!-- other junk doesn't matter --> </itemtemplate> </asp:repeater>
on page however, have same setup, reason whenever put inside itemtemplate, drops out of context , can no longer reached code-behind. ex:
<asp:repeater id="repeaterthatmakesmesad" runat="server" onitemdatabound="repeaterthatmakesmesad_onitemdatabound"> <itemtemplate> <asp:literal id="litsadliteral" runat="server" /> <!-- other junk doesn't matter --> </itemtemplate> </asp:repeater>
on first page, lithappyliteral reachable code-behind, on other 1 litsadliteral not.
any ideas? using asp.net 3.5.
here's of codebehind can share:
protected void repeaterthatmakesmesad_onitemdatabound(object sender, repeateritemeventargs e) { // logging junk // guard clauses try { xmlnode myitem = (e.item.dataitem xmlnode); if(myitem != null) { litsadliteral.text = "sadness."; } // end if } // end try } // method
under these conditions, "litsadliteral" not exist in current context.
i figured out doing wrong (see answer below), if still willing explain why literal drops out of reachable context it's placed within confines of itemtemplate of repeater, i'd appreciate it.
i realized going on.
in 'working' example, didn't directly reach literal. 'went searching' first.
in working one, didn't have:
lithappyliteral.text = "happy!";
i had:
literal lithappyliteral = (e.item.findcontrol("lithappyliteral") literal); if(lithappyliteral != null) { lithappyliteral.text = "happy!"; }
now i'm doing on other page working. sorry taking everyone's time.
i don't know process here sure, should delete question or leave in case blunder/solution in future?
Comments
Post a Comment