开发者

updatepanel doesnt update correctly, must click twice to update

I am using an update panel and when I click a button it will 开发者_Go百科update all the panels.

updapanel1.update() is very simple, but my data is not updating unless I hit the button twice.

My gridviews shows data for a selected user, and then all the grids reflect that users data. works fine all the update panels work for the gridviews.

Now for somereason when i try to do a row count and update the panel with the summary, it does not work, i get either the previous users summary or if i hit update again for the same user i get the correct data.

'the grids are in these panels
     UpdatePanel1.Update()
            UpdatePanel2.Update()
            UpdatePanel4.Update()
            UpdatePanel6.Update()
            UpdatePanel7.Update()

'the things that are not updateing correctly
            rqnum.Text = GridView3.Rows.Count
            oknum.Text = GridView4.Rows.Count
            xlnum.Text = GridView5.Rows.Count
            dynum.Text = DataList1.Items.Count

            UpdatePanel8.Update()
            Panel1.Visible = False


Without seeing the code for this we cannot guarantee that we are giving you the right answer, but just a thought. If the code you posted is the actual code, I would re-order things a bit.

  1. Do the updates to the content
  2. Then call "update" on the panels

This ensures that your content updates are actually sent to the panels. My guess is this is why it takes that second click. So something like this.

'Update content and toggle visibility of controls
rqnum.Text = GridView3.Rows.Count
oknum.Text = GridView4.Rows.Count
xlnum.Text = GridView5.Rows.Count
dynum.Text = DataList1.Items.Count
Panel1.Visible = False

'Now update all needed panels
UpdatePanel1.Update()
UpdatePanel2.Update()
UpdatePanel4.Update()
UpdatePanel6.Update()
UpdatePanel7.Update()    
UpdatePanel8.Update()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜