2011-02-18 51 views
2

我正在使用更新面板,當我單擊按鈕時,它將更新所有面板。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 

回答

2

在沒有看到代碼,這一點,我們不能保證我們給你正確的答案,但只是一個想法。如果你發佈的代碼是實際的代碼,我會重新排列一些東西。

  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