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
Alan Silver
(anything added below this line is nothing to do with me)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.
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Alan Silver" wrote:
> 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
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
>
>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
Alan Silver
(anything added below this line is nothing to do with me)
Saturday, March 31, 2012
Why is the repeater empty in a postback?
Labels:
air,
asp,
below,
code,
contains,
empty,
form,
ltbrgtltaspliteral,
net,
postback,
repeater,
shown,
simplified,
theitemtemplate,
version
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment