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
380
Binding to a Dataset
posted

I have a four table dataset that I am binding to my tree.  I have the relations set up and the tree displays as I would expect.  I had some issues setting a key and tag but put the following code in that seems to have sorted that part out.

void treeDocumentType_InitializeDataNode(object sender, InitializeDataNodeEventArgs e)
{
    switch (e.Node.BandName)
    {
        case "tblClass":
            e.Node.Key = ((DataRowView)e.Node.ListObject)["uidClass"].ToString();
            break;

        case "relClassMember":
            e.Node.Key = ((DataRowView)e.Node.ListObject)["uidMember"].ToString();
            break;

        case "relMemberSummary":
            e.Node.Key = ((DataRowView)e.Node.ListObject)["uidSummary"].ToString();
            break;

        case "relSummaryPhrase":
            e.Node.Key = ((DataRowView)e.Node.ListObject)["uidPhrase"].ToString();
            break;
    }
}

I suppose the first question is if this is the accepted way to set those variables or should I be doing something else.

The issue that I am having is reselecting a node after performing an operation.  I can easily re-bind the tree which work, but I can't make the previously selected node re-select.  I tried using

 treeDocumentType.GetNodeByKey(e.MemberId.ToString());

where e.MemberId is the Guid that was previously selected.  That result comes back as null.  However if I set a breakpoint and then open up the immediate window I can make the following query

?treeDocumentType.Nodes[0].Nodes[0].Key

this will show the correct key.  If I then re-execute the GetNodeByKey bit it will work.  Is there a better way to do this?

Thanks, I appreciate any insight.