textbox inside a repeater control

  • Thread starter Thread starter Andy Fish
  • Start date Start date
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
 
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
 
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
 
Back
Top