Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Being my first post here, I'd like to say hello. :-D

I'm working on a ASP.NET project and I wan't to read OPC-DA data. The data reading works fine, but I can't get the updatepanel to refresh automatically.

When new data arrives, a 'DataChange' event is thrown by the 'OpcGroup' object. In this event I want to refresh the update panel manually (conditional). So I've set the updatemode=conditional on the UpdatePanel1. When I click the update button with my mouse, the update works. But when I click the button programmatically, the update doesn't work.

Does anyone have an idea why this doesn't work (or a better idea)?


VB
Private Sub objOpcGrps_DataChange(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles As System.Array, ByRef ItemValues As System.Array, ByRef Qualities As System.Array, ByRef TimeStamps As System.Array) Handles objOpcGrp.DataChange
    'declaration
    Dim i As Integer
    'update status tags
    For i = 1 To ClientHandles.Length
        If ClientHandles(i) = 1 Then txtWaarde3.Text = ItemValues(i)
        If ClientHandles(i) = 2 Then txtWaarde3.Text = ItemValues(i)
    Next
    'Click update button to refresh updatepanel
    btnUpdate_Click(btnUpdate, New System.EventArgs)
End Sub

SQL
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
    UpdatePanel1.Update()
End Sub
Posted

Call the update of other update panel directly.
Try:
VB
Private Sub objOpcGrps_DataChange(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles As System.Array, ByRef ItemValues As System.Array, ByRef Qualities As System.Array, ByRef TimeStamps As System.Array) Handles objOpcGrp.DataChange
    'declaration
    Dim i As Integer
    'update status tags
    For i = 1 To ClientHandles.Length
        If ClientHandles(i) = 1 Then txtWaarde3.Text = ItemValues(i)
        If ClientHandles(i) = 2 Then txtWaarde3.Text = ItemValues(i)
    Next
    ' Call the update of the other update panel here itself
    UpdatePanel1.Update()
End Sub


The reason it does not work as you intend to is because of the page life-cycle and the way and when the click has been called for.
 
Share this answer
 
This isn't working either.

Now I get error: The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' before Render.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900