Amit Dhall
Amit Dhall

Reputation: 1315

Treeview in Asp.net

I have a TreeView in master page that is bound on each page and I want that it not to be so.

Upvotes: 0

Views: 248

Answers (2)

Pranay Rana
Pranay Rana

Reputation: 176906

User cache to store the datasorce which you are going to bind with the treeview control and on each postpaback check cache varialble is null or not.

For example like below :

public DataSet MenuTable
    {
        get
        {
            if (HttpContext.Current.Cache["MenuTable"] == null)
            {
                DataSet dsmenu = null;

                    dsmenu =GetMenuData(HttpContext.Current.Session["RolePkey"].ToString());

                HttpContext.Current.Cache["MenuTable"] = dsmenu;
                return dsmenu;
            }
            else
            {
                return (DataSet)HttpContext.Current.Cache["MenuTable"];
            }
        }
    }

Upvotes: 1

Pieter Germishuys
Pieter Germishuys

Reputation: 4886

Don't place the treeview on the master page then? If you want to bind it conditionally, you could store a session state variable that specifies when the treeview is supposed to be bound.

Upvotes: 0

Related Questions