textbox inside a repeater control

A

Andy Fish

Hi,

I have a forrm with viewstate disabled (to try and optimize network
performance). I have come a bit unstuck though when I use a repeater with a
textbox inside it

Obivously with viewstate disabled, the repeater contains no items on
postback unless I databind it. however, this causes the posted textbox
values to be overwritten with the databound ones.

is there any way to do the databind before the posted values are applied, or
do I have to enable viewstate for this form after all?

TIA

Andy
 
Y

Yunus Emre ALPÖZEN [MVP]

Hi Andy,
u should enable viewstate of your repeater. If viewstate is not enabled for
a control it will be re-constructed. that will cause to lose its state as u
have experienced. Enabling only repeater's viewstate is enough for your
case.

--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET
Microsoft .NET & Security MVP
 
G

Guest

Hi Andy,

You can have a Page level Arraylist (or Hashtable) for storing values from
textboxes in the repeater. When postback retrieve values first, the rebind
the repeater:

if(IsPostBack)
{
list = new ArrayList();
foreach (RepeaterItem item in repeaterObj.Items)
{
TextBox txt = item.FindControl(txt_ID) as TextBox;
list.Add(txt);
}
}

repeaterObj.DataSource = dataObject;
repeaterObj.DataBind();


HTH

Elton Wang
 

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,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top