Can't get DataSource of a repeater, returns null

A

Alan Silver

Hello,

I am using a repeater on a page, and on postback would like to get hold
of the ArrayList that I used to populate the repeater. I thought that I
should be able to do something like...

ArrayList arrStuff = (ArrayList)rptStuff.DataSource;

but this comes back as null. I bound the repeater to an ArrayList when
the page first loaded.

Any idea why I can't do this? The SDK seems to imply you can read as
well as set the DataSource.

TIA
 
K

Karl Seguin

You can't afte a postback. The original datasource isn't maintained for you
in viewstate, only the data necessary to render the control in the form of
repeater items.

Only solution is to reget the data from the database, typically people cache
it somehow (in the Session if it's specific per-user), or ni HttpCache if
it's global...

Karl
 
A

Alan Silver

You can't afte a postback. The original datasource isn't maintained for you
in viewstate, only the data necessary to render the control in the form of
repeater items.

Oh, that's a shame. The way the SDK phrased it, it sounded like you
could just pull out an ArrayList.
Only solution is to reget the data from the database, typically people cache
it somehow (in the Session if it's specific per-user), or ni HttpCache if
it's global...

Even easier (ie less resources), just loop through the repeater and
rebuild it!! That's what I was already doing, but I thought I could save
some lines of code by pulling out a ready-made ArrayList. Looks like
I'll keep what I've got!!

Thanks for the reply.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top