2010-04-22 36 views

回答

3

不知道爲什麼發生這種情況,但我有一個修復它。令人驚訝的是,我能找到的每一個HierarchicalDataBoundControl的例子(甚至來自msdn)都是這樣做的。但是,這是一個解決方法。

private bool dataBound = false; 
    protected override void OnInit(EventArgs e) 
    { 
     base.OnInit(e); 
     if (this.Page.IsPostBack) 
     { 
      this.DataBound += delegate { dataBound = true; }; 
      this.Page.Load += delegate { if (!dataBound) DataBind(); }; 
     } 
    }