c# - With a custom control that's inside of an ItemTemplate (Repeater), how can I access values from the repeater item? -
i have control, custom button. button sits inside of <itemtemplate>
. i'm needing access databound values parent, <itemtemplate>
.
for example, <%#eval("firstname")%>
can done within <itemtemplate>
, not within control itself, other exposing values via property tags.
note: know how pass these values via property/attribute tags. can't in case.
i've been playing around databinder.eval
can't seem access need.
examples of attempts:
dim parent repeateritem = ctype(me.namingcontainer, repeateritem) dim test = databinder.eval(parent.dataitem, "firstname") test = databinder.eval(me.namingcontainer, "dataitem.firstname") test = databinder.eval(directcast(directcast(parent, repeateritem), idataitemcontainer).dataitem, "firstname")
i've never had before, , want strictly code-behind. can climb control tree , see "namingcontainer" in fact repeateritem.
am missing something? c# or vb.net examples welcome. convert it.
as mention, best way parse values via properties.
and i'm not sure can access dataitem object in post-back scenario you're thinking off.
i think you'll have access values via control tree custom control, isn't terrible pretty.
for example. assume repeater item has literal called "yourliteral" along side submit button "yourbutton". in code file "yourbutton" , it's submit event, like:
(c#)
((literal) ((repeateritem) this.parent).findcontrol("yourliteral")).text
to text value. , substitute control types relevant you.
Comments
Post a Comment