locked
how to refresh screen automatically after updating data RRS feed

  • Question

  • User1835225731 posted

    hi,

    I have one page and 2 different of gridview. Each gridview has total value at the footer. These total value I compared and show the warning message if the value is not equal. Thats mean total gridview1 must equal to gridview2. If not equal user need to update the total at the gridview1. After updating data, and make the value of gridview1 equal to gridview2, the message still there..unless I refresh it manually. Can anyone help me with this? Below if my coding

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
            If e.Row.RowType = DataControlRowType.DataRow Then
                dtotal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Total_SPA"))
            End If
            If e.Row.RowType = DataControlRowType.Footer Then
                e.Row.Cells(7).Text = "Current Membership Value:"
                e.Row.Cells(8).Text = dtotal.ToString("c")
    
            End If
    
        End Sub
    Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView2.RowDataBound
            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim rowTotal As Decimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SPA"))
                grdTotal = grdTotal + rowTotal
            End If
    
            If e.Row.RowType = DataControlRowType.Footer Then
                e.Row.Cells(6).Text = "Total:"
                e.Row.Cells(7).Text = grdTotal.ToString("c")
            End If
        End Sub
    
        Protected Sub GridView3_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView3.RowDataBound
            Dim total As Decimal = Convert.ToDecimal(True)
            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim rowTotal As Decimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SPA"))
                subTotal = subTotal + rowTotal
            End If
    
            If e.Row.RowType = DataControlRowType.Footer Then
    
                e.Row.Cells(4).Text = "Total:"
                e.Row.Cells(5).Text = subTotal.ToString("c")
    
    
                total = grdTotal + subTotal
                TextBox2.Text = total
    
                If (dtotal = total) Then
                    Label9.Text = ""
                Else
                    Label9.Text = "Please Update!"
    
                End If
    
            End If
    
        End Sub



    Tuesday, September 24, 2013 3:03 AM

Answers

  • User-2082479761 posted

    Here is the example using jQuery.

    <?php
    
    //  Call this function when data changes
    function update_clients()
    {
        mysql_query( "UPDATE pageGen SET id = id + 1 LIMIT 1" );
    }
    
    //  Call this function to get the ID to pass to JavaScript
    function get_update()
    {
        $result = mysql_query( "SELECT id FROM pageGen LIMIT 1" );
        $update = mysql_result( $result, 0, 'id' );
        return $update;
    }
    
    ?>

    When the page is initially loaded, populate a JavaScript variable with a number from the database:

    <script type="text/javascript">
    var pageGenID = 25218603  //  generated by PHP
    var processUpdate = function( response ) 
    {
        if ( pageGenID < response ) 
        {
            replace_current_data_with_new_via_ajax();
            pageGenID = response;
        }
    }
    //  Compare our Page Generate ID against that of the server
    var checkUpdates = function()
    {
        serverPoll = setInterval( function()
        {
            $.get('script_to_return_latest_pageGenID.php', 
              { lastupdate: 1 }, 
              processUpdate, 'html');
        }, 10000 )
    };
    
    //  Check for updates every 10 seconds
    $( document ).ready( checkUpdates );
    
    </script>




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 4:55 AM

All replies

  • Tuesday, September 24, 2013 3:34 AM
  • User-2082479761 posted

    Here is the example using jQuery.

    <?php
    
    //  Call this function when data changes
    function update_clients()
    {
        mysql_query( "UPDATE pageGen SET id = id + 1 LIMIT 1" );
    }
    
    //  Call this function to get the ID to pass to JavaScript
    function get_update()
    {
        $result = mysql_query( "SELECT id FROM pageGen LIMIT 1" );
        $update = mysql_result( $result, 0, 'id' );
        return $update;
    }
    
    ?>

    When the page is initially loaded, populate a JavaScript variable with a number from the database:

    <script type="text/javascript">
    var pageGenID = 25218603  //  generated by PHP
    var processUpdate = function( response ) 
    {
        if ( pageGenID < response ) 
        {
            replace_current_data_with_new_via_ajax();
            pageGenID = response;
        }
    }
    //  Compare our Page Generate ID against that of the server
    var checkUpdates = function()
    {
        serverPoll = setInterval( function()
        {
            $.get('script_to_return_latest_pageGenID.php', 
              { lastupdate: 1 }, 
              processUpdate, 'html');
        }, 10000 )
    };
    
    //  Check for updates every 10 seconds
    $( document ).ready( checkUpdates );
    
    </script>




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 4:55 AM