Tag Archives: טרעעוויעוו

ארבעטן מיט טרעענאָדעבינדינג אין די 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