updatepanel没有正确更新,必须点击两次才能更新

问题描述:

我正在使用更新面板,当我单击按钮时,它将更新所有面板。updatepanel没有正确更新,必须点击两次才能更新

updapanel1.update()非常简单,但是我的数据没有更新,除非我按了两次按钮。

我的网格视图显示选定用户的数据,然后所有网格反映该用户数据。 正常工作所有更新面板都适用于GridView。

现在因为某些原因,当我尝试进行行计数并更新面板与摘要,它不起作用,我得到以前的用户摘要或如果我再次更新为同一用户更新我得到正确的数据。

'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 

在没有看到代码,这一点,我们不能保证我们给你正确的答案,但只是一个想法。如果你发布的代码是实际的代码,我会重新排列一些东西。

  1. 执行更新内容,
  2. 然后调用“更新”面板上

这可确保内容更新实际发送到面板。我的猜测是这就是为什么需要第二次点击。所以像这样的东西。

'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

继承人的事情,我updateing我的GridView的,然后我想更新与拥有我所有的行数GridView的的计数(单独为每个网格)标签 – MyHeadHurts 2011-02-18 18:44:23