Why is the repeater empty in a postback?

A

Alan Silver

Hello,

I have a form that contains a repeater. A simplified version of the
ItemTemplate is shown below (air code)...

<br><asp:Literal id="litID" runat="server" />
<br><asp:TextBox id="txtQty" runat="server" />
<hr>

This basically shows a list of item IDs, with quantities for each one.
The quantity is in a text box so the user can change it. I set the Text
properties in the ItemDataBound event.

When the page is posted back, I want to go through the repeater and
update a database based on the info in it. After that, I will bind the
repeater to the database data and have the new info displayed.

The problem is that the repeater does not contain any items on postback.
I tried looping through the Items collection, but it's empty. The tag
for the repeater looks like...

<asp:Repeater ID="rptBasket" OnItemDataBound="rptBasket_ItemDataBound"
RunAt="Server">

so it's not that I've turned off the view state.

The one point that might be relevant here is that the repeater and its
code are inside a user control. Don't know if this makes any difference.

Any ideas? I know the info is there, as if I dump the form contents to
the page, I see form fields with names like
_ctl3:rptBasket:_ctl2:txtQuantity which shows the textbox values are
there. I don't see anything for the literals though.

Please help, I'm really stuck here. TIA
 
G

Guest

you will have to do a FOR EACH item in the repeater's collection and use the
FindControl() call to capture the textbox to get the value.
 
A

Alan Silver

you will have to do a FOR EACH item in the repeater's collection and use the
FindControl() call to capture the textbox to get the value.

That's what I did, but as I explained, the repeater's collection was
empty. I have done this sort of thing many times before without problem,
I just wonder if it was the fact that the repeater was in a user control
that made this different.

Any idea? TIA
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top