locked
UpdatePanel out of synch RRS feed

  • Question

  • User-962670764 posted

    I have about given up on using an odometer to track my users bike rides.  Instead I have a text box on the master page that is updated when rides are added or deleted. A GridView (gvrides) in the content page does the adding and deleting. A Modal popup gives them a form to add rides and the deletes are done right from the grid. This is the Master page update panel. Just a label that displays the number of miles.

       <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" ><ContentTemplate>
                                <asp:Label ID="lbdistytd" runat="server"></asp:Label>
                                    </ContentTemplate>
                               </asp:UpdatePanel>

    After the Insert and delete I update the master Update Panel.

    //INSERT:  
    
    retval = st.insertlog(Convert.ToInt32(hfrid.Value), dtride, distmiles, distkm, distunit, totalminutes, totalrideminutes, rtype, rcm, htemp, ltemp, tempu, egain, eunit, bikeid, multi);
                gvrides.DataBind();
                UpdatePanel up;
                up = (UpdatePanel)Master.FindControl("UpdatePanel1");
                up.Update();
                loadgrid(yr, mo);
                clearform();
    
    //DELETE:
    
     stats st = new stats();
                    st.DeleteRide(rideid);
                    gvrides.DataBind();
                    UpdatePanel up;
                    up = (UpdatePanel)Master.FindControl("UpdatePanel1");
                    up.Update();

    This does seem to update the label but it is one action behind. When I do the first insert the label does not change, If I then delete a ride (or add another) the label updates to the previous value. e.g. Label= 2000 Add 350 > label = 2000 delete 100 label = 2350 add 200 label = 2250. etc. Anyone know whats going on?

    This is another twist...   There is also another Detail Button on the Gridview that opens a modal popup the just displays all the data for the ride. That popup has an Edit button that opens an editable modal popup. Changing the distance on that one, and pressing save returns you to the detail popup which has an ok button that just closes the detail  popup, however in that case the Master label is updated correctly. ??

    Friday, March 4, 2016 9:07 PM

Answers

  • User61956409 posted

    Hi dieseldave,

    This does seem to update the label but it is one action behind. When I do the first insert the label does not change, If I then delete a ride (or add another) the label updates to the previous value. e.g. Label= 2000 Add 350 > label = 2000 delete 100 label = 2350 add 200 label = 2250. etc. Anyone know whats going on?

    You could try to get the number of miles after you add or delete miles by query from your database, then you could assign the value to “lbdistytd” Label and update UpdatePanel control to update content.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 7, 2016 3:07 AM