Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
Pre-populate which nodes are checked on Bind/PreRender
posted

I use a WebTree control to have a user enter information into a database, but have to give him the ability to edit and update the same entry later. For this, I need to populate the tree with the same nodes checked as when the information was initially submitted.

I return a DataSet with the checked  DataKey values (a Unique ID in the Database), so as each node is created, I can check it's LevelKeyField value and match the ones which needs to be rendered as checked, but how and where?

Here is the basic outline of my TreeView Population method:

//Get a DataAdapter
            SqlDataAdapter da = (SqlDataAdapter)GetTreeViewData(Status);
      
            //Create a DataSet and fill the dataset
            DataSet ds = new DataSet("aacacacacac");
            da.Fill(ds, "aacacacacac");

            try
            {
                // Set up Relationships
                ds.Relations.Add("aaaaaa", ds.Tables["acacacac"].Columns["UniqueID"],ds.Tables["acacacac"].Columns["UniqueID"]);
            }
            catch (Exception x)
            {
                string s = x.Message;
                this.lblErrorMessage.Text = x.Message;
            }
        //Set TreeView Settings

        this.tvRecipients.LoadOnDemandPrompt = "<em>loading collectors</em>";
        this.tvRecipients.DataKeyOnClient = true;
        this.tvRecipients.DataSource = ds.Tables["XXXXXXXX"].DefaultView;
        this.tvRecipients.Levels[0].LevelKeyField = "UniqueID";
        this.tvRecipients.Levels[0].RelationName = "ccccccc";
        this.tvRecipients.Levels[0].ColumnName = "dddddddd";
        this.tvRecipients.Levels[1].ColumnName = "rrrrrrrrr";
        this.tvRecipients.Levels[1].LevelKeyField = "UniqueID";
        this.tvRecipients.DataBind();

Parents Reply Children
No Data