Reference repeater data

  • Thread starter Thread starter Joel
  • Start date Start date
J

Joel

Hey all-

I'm new to asp.net so please bear with me -- I'm attempting to
reference the repeater's Container.DataItem outside the repeater
object.

In other words -- In a seperate sub routine: if the repeater's
Container.DataItem == Something -> Do Action. How do I reference the
Container.DataItem in by sub routine (And thus outside the repeater
object)?

Thanks!
 
Hi,

from where do you call the subroutine or it gets called? If that Do Action
is your subroutine, couldn't you just apss reference to it. Anyways, please
provide a bit more details.
 
The repeater is obivously part of the html code - I'd like to reference
the Container.DataItem from the vb.net code from above. I can reference
the repeater object just find - I just can't get to the
Container.DataItem from the repeater object. Is this possible?

-Joel
 
I see,

Container.DataItem is available only inside Repeater's template and only for
the request after DataBound is called. In practise means that you'd access
it from Repeater's ItemDataBound event in addition to the template itself
(e.g meaning that template accesses it via databinding expressions). So in
that sort it's not available. Repeater and itas child controls (in
templates) only have knowledge of its data and access to it

However, if you bind the Repeater say to a DataTable or a DataSet, you could
have the data source object (ds/dt) available via a public member on the
code-behind class so that repeater can bind to it, but the data is also
consumable. Means that you have a public member on the class, and you load
the dt(ds to it with ADO.NET). Repeater is then just one consumer for the
data. Or not being the only option, you could just access the data in
Page_Load etc before you bind the dt/ds to repeater and set Text's of
Label's and textBoxes before binding etc etc. Possibilities are endless.

If you want more concrete help, provide a sample of your code & scenario.
 
Thanks for the assistance - I was able to access the data using the ds
object. Thanks!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top