我正在調試一個非常複雜的系統,我沒有編碼。在回帖後我得到這個錯誤:在前一個請求期間,控制樹與視圖狀態不匹配
Exception: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
我不是很熟悉視圖狀態如何加載和工作。該代碼建立了一些網格視圖和dynamicaly控制,並將其插入到一個名爲phCallsDynamicGridHolder
創建異常的代碼佔位符始終是與此類似:
HtmlGenericControl summary = createNewCallsSummary(calls);
GridView gv = createGridView(calls, "Calls", width);
phCallsDynamicGridHolder.Controls.Add(summary);
phCallsDynamicGridHolder.Controls.Add(gv);
phCallsDynamicGridHolder.Controls.Add(createNewCallsTotalSummary());
是任何人都熟悉的是什麼原因導致這種例外?該網頁幾乎是2000行代碼,我會根據需要儘可能多地過去。
可能出現[無法加載視圖狀態。視圖狀態被加載到的控制樹](http://stackoverflow.com/questions/11795994/failed-to-load-viewstate-the-control-tree-into-which-viewstate-is-being-loaded) – 2013-08-25 07:09:00