Issues with OnTextChanged using <asp:Repeater

  • Thread starter Thread starter Fred Dag
  • Start date Start date
F

Fred Dag

As far as I can work out when using the OnTextChanged event I cannot get the
TextBox and Labels values when the event fires as they are populated by a
<asp:repeater and so don't have values.

If I try to give the repeater values by removing
if (!IsPostBack)

{}

from the

Page_Load() method then my method is not called by the OnTextChanged event.

There is probably a limitation with my understanding of the event model.

How should I be getting OnTextChanged events from a <asp:repeater component
and getting details about the values from the other controls of the
<ItemTemplate> line that caused the event to trigger?



Thanks in advance
 
Hi,

if you have specific problems can you show the code?

Anyways, if you get TextChanged event to be raised, you can get to the
current repeater's item via sender (first argument in event handler method)
with code as follows:

RepeaterItem ritem =(RepeaterItem)((Control)sender).NamingContainer;

It would be the the parent item of the TextBox which raises this specific
TextChanged event. Then getting to other controls on the same item would be
just running FindControl againts the RepeaterItem

Label lbl=(Label)ritem.FindControl("Label1");

and so on
 

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

Back
Top