views:

42

answers:

1

The title says it all.

I am binding to a SiteMapDataSource (hierarchical).

I am overriding PerformDataBinding to grab the data from the datasource.

Everything works great on page load. But when I perform a postback anywhere on the page, the PerformDataBinding method does not get called, and in effect, not rendering any menu items (PerformDataBinding wasn't called).

+1  A: 

No clue why this is happening, but I have a fix for it. Amazingly, every example of a HierarchicalDataBoundControl I could find (even from msdn) was doing this. However, here is a workaround.

    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(); };
        }
    }
Paul Knopf