ארבעטן מיט טרעענאָדעבינדינג אין די ASP.NET טרעעוויעוו קאָנטראָל

I’ve been working on what I hope will be a soon-released קאָדעפּלעקס project that provides a nice integrated bit of web parts talking to each other via provider/consumer connections for the purpose of exploring a SharePoint site under the covers.  (דעם האט אַוואַדע געשען איידער, but this is a learning project as much as anything else).  This is meant to be a replacement for the windows explorer view of SharePoint 2010 דאָקומענט לייברעריז.

The code has the usual recursive call down the SPWeb’s and SPLists from a given starting point.  The object that does all that traversing builds up an XML string that looks something like this:

<sitecollection url=’הטטפּ://demo2010a:9090′>
 
<web
     title=’Hello World Sandbox’ 
     Template=’A site for teams to quickly organize, author, and share information, BLAH BLAH BLAH’>

     <רעשימע
        title=’BCC_Health_Services_FAQs’
        Template=’CustomList’
       
listid=’הטטפּ://demo2010a:9090/helloworldsandbox[delim]1e02b001-3cb2-4f17-b63d-7809e86b4174′>
    
</רעשימע>

     <רעשימע
        title=’BCC_Notifications’ 
        Template=’CustomList’ 
        listid=’
הטטפּ://demo2010a:9090/helloworldsandbox[delim]5a5a13d1-877c-41c0-9063-b9612be80d5e’>
     </רעשימע>

  </web>

</sitecollection>

I expect to clean up that XML before all is said and done.

I want to ultimately get that information up and into a Treeview control.  Not exactly earth shattering stuff.

The challenge I took on here was to connect the tree view to an XML Data Source control instead of manually building up my treenodes as I traverse the tree.  I did this partly because I’m deliberately making things harder on myself (this is a learning project after all) and partly because I have this vague notion that building up tree nodes as I traverse the tree isn’t a good idea for the long term.

The problem with this approach is that the Treeview control doesn’t know about the good attributes on the interesting nodes like “list” or “web” so it shows this output by default:

 

image

That’s not useful.  This is where the TreeNodeBinding class helps.  I can use this to tell the Treeview control how it should interpret the XML.  דאָ ס אַ בייַשפּיל:

tnb = new TreeNodeBinding();
tnb.DataMember = "list"; // This is the label in the xml for a site.
tnb.TargetField = "listid";
tnb.ValueField = "title";
tnb.ToolTipField = "Template";

This binding tells the treeview that when it finds a <רעשימע> node in the XML, apply the bindings for TargetField, ValueField and ToolTipField.  In may app, these map as follows:

  • TargetField: When someone clicks on a node value, this is what you’ll get for SelectedNode.Value.  This is not to be confused with…
  • ValueField: This is what you want the Treeview to display to the user.
  • ToolTipField: The value from the XML that you want as a Tooltip.

Add that TreeNodebinding to the tree view’s DataBindings and you get output like this:

 

image

I’ll have more on all this as I continue on the project and eventually put this up on Codeplex.

</עק>

אַבאָנירן צו מיין בלאָג.

גיי מיר אויף טוויטטער בייַ http://www.twitter.com/pagalvin

3 געדאנקען אויף "ארבעטן מיט טרעענאָדעבינדינג אין די ASP.NET טרעעוויעוו קאָנטראָל

  1. Pingback: Tweets that mention Working With TreeNodeBinding in the ASP.NET Treeview Control « Paul Galvin's SharePoint Space -- Topsy.com

  2. Holger

    הי פאולוס,

    I just checked that myself. It worked as far as you described that even if I don’t get that information from your site (what a pity :-)).
    The point I am interested in is, I tried to make the structure lazy loading with the PopulateOnDemand property. Otherwise the treeview load the complete structure in a whole which I would like to avoid. This property PopulateOnDemand seems not to have any effect.

    Also the treeview does not save any expand/ collapse state information.

    Did you solve these issues?

    גרוס

    Holger

לאָזן אַ ענטפֿערן

אייער בליצפּאָסט אַדרעס וועט ניט זיין ארויס. Required fields are marked *