Changing value of dynamic control in Page_Load after creating the

G

Guest

I have a multithreaded application is ASP.NET that checks the status of a
process every 2 seconds. After the thread has completed, the values of
dynamically added controls need to be changed depending on the return value
from the process just completed on the second thread. The problem I am having
is that while the code seems to work correctly (I am performing a
response.write and writting out the values as a HTML comment), the final
display to the end user shows the initial value set to the dynamic control.

Any idea why this is happening? Any help will be welcome.

Here is what I am doing:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim oThread AS CustomThreadClass
Dim oControl AS DropDownList

'build all the dynamic controls
BuildDynamicControls

'if this is a postback - check the status of the thread and change value
of dynamic control
If IsPostBack Then
oThread = Session("Threading")
If Not oThread Is Nothing Then
If oThread.Status = oThread.StatusEnum.Completed Then
'find the dynamic control by using a custom method that recursively
searches for the dynamic control
oControl = FindControlByName("lstStatus")
oControl.SelectedItem = 2
Response.Write ("<!-- Value: " & oControl.Text & " -->")
End If
End If
End If

'code to sleep for 2 seconds and refresh page goes here - will not
replicate this

End Sub
 
G

Guest

I found the answer. The value of the dynamically loaded control must be
changed in the Page_PreRender event.
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top