473,756 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't get DataSource of a repeater, returns null

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)rptS tuff.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

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #1
2 5915
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

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:Fy******** ******@nospamth ankyou.spam...
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)rptS tuff.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

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #2
>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.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5319
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted user controls. Worse I'm trying to add dynamic user controls from within a repeater loop (looping through attributes)... I bind to a function in the code behind and pass in the attribute. <asp:repeater id="rAttributes" Runat="server">
2
5521
by: Ed Allan | last post by:
I have extended the example at http://support.microsoft.com/default.aspx?scid=kb;EN- US;306154 to build a webform page with 3 layers of nested Repeaters (ie. parent, child and grandchild). I added a third DataTable to the DataSet, and created a second Relation between the second and third DataTables. On the aspx page I copied the child Repeater to create the grandchild, referencing the second Relation.
3
2137
by: Mark | last post by:
I am looking for an example of using checkboxes in a repeater control where the checkbox state is persisted from page to page. Thank you, Mark
0
982
by: Fred Dag | last post by:
Hi, I have a Repeater that is filled with a PagedDataSource and upon receiving a OnTextChanged event from an <ItemTemplate> Textbox I attempt need to get details from the row in the DataSet such as its row ID. When I try to do this I get a NullReference Exception. Code looks like this: Repeater repeaterCI = (Repeater)((Control)sender).NamingContainer.Parent; Response.Write("(DataSet)repeaterCI.DataSource" +
1
1237
by: Fred Dag | last post by:
Hi, I am trying to get the DataSet from a Repeater using its DataSource property from an event handler. I am getting Null instead. Should the DataSource persist when the event hadler is called or is Null the expected result? Still trying to understand the event model.
2
5100
by: shapper | last post by:
Hello, I created a Repeater at runtime with an AccessDataSource.Everything Works fine! Now I need to use the same repeater but with a DataSource created in my VB.Net code. I created a DataView but the Repeater doesn't show anything! I don't get any error so I have no idea what is going on.
2
1313
by: champ.supernova | last post by:
I have a repeater, which contains in its <HEADERTEMPLATEa drop-down list (set to autopostback). If the page is a postback, I want to modify the SQL of the repeater's datasource, DEPENDING ON the value of the drop-down list. However, I can't evaluate the drop-down list submission at Page_Load, because the repeater has not yet been databound or rendered, so effectively the drop-down list doesn't yet exist.
0
1754
by: Adam Knight | last post by:
Hi All, I have a repeater control nested inside another repeater control. The nested (child) repeater control, is bound to an object data source. My problem is, i need to send a data item value from the 'item' of parent control as a parameter to the object datasource of the child repeater control. Any thoughts on how to best do this? Declaritively?
2
11581
by: shahiz | last post by:
basically im having null pointer exception //read an inputstream is = new DataInputStream(new FileInputStream("test.mpg")); loadBytes(is); //pass it as a datasource for the player public void loadBytes(InputStream is){ DataSource ds=new DataSource(is); player = Manager.createPlayer(ds);
0
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9819
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.