ಟ್ಯಾಗ್ ಆರ್ಕೈವ್ಸ್: TreeNodeBinding

ASP.NET Treeview ಕಂಟ್ರೋಲ್ ರಲ್ಲಿ TreeNodeBinding ಕೆಲಸ

ನಾನು ಭಾವಿಸುತ್ತೇವೆ ಏನು ಕೆಲಸ ಮಾಡಲಾಗಿದೆ ಬಂದಿದೆ ಒಂದು ಶೀಘ್ರದಲ್ಲೇ ಬಿಡುಗಡೆ ಇರುತ್ತದೆ CodePlex ಕವರ್ ಅಡಿಯಲ್ಲಿ ಒಂದು ಶೇರ್ಪಾಯಿಂಟ್ ಸೈಟ್ ಅನ್ವೇಷಿಸುವ ಉದ್ದೇಶಕ್ಕಾಗಿ ಒದಗಿಸುವವರು / ಗ್ರಾಹಕ ಸಂಪರ್ಕಗಳ ಮೂಲಕ ಪರಸ್ಪರ ಮಾತನಾಡಿಕೊಳ್ಳಲು ವೆಬ್ ಭಾಗಗಳ ಒಂದು ಸಂತೋಷವನ್ನು ಸಮಗ್ರ ಬಿಟ್ ಒದಗಿಸುವ ಯೋಜನೆ.  (ಈ ಖಚಿತವಾಗಿ ಮೊದಲು ಮಾಡಿಲ್ಲ, ಆದರೆ ಈ ಒಂದು ಕಲಿಕಾ ಯೋಜನೆಯನ್ನು ಹೆಚ್ಚು ಮಾಹಿತಿ ಬೇರೆ ಏನು ಆಗಿದೆ).  ಈ ಶೇರ್ಪಾಯಿಂಟ್ ನ ವಿಂಡೋಸ್ ಎಕ್ಸ್ ಪ್ಲೋರರ್ ವೀಕ್ಷಣೆಗಾಗಿ ಬದಲಿ ಅರ್ಥೈಸಲಾಗಿತ್ತು ಇದೆ 2010 ಡಾಕ್ಯುಮೆಂಟ್ ಗ್ರಂಥಾಲಯಗಳು.

ಕೋಡ್ SPWeb ಮತ್ತು ಕೊಟ್ಟಿರುವ ಆರಂಭದ ಹಂತದಿಂದ SPLists ಕೆಳಗೆ ಸಾಮಾನ್ಯ ಪುನರಾವರ್ತಿತ ಕರೆಯು ಹೊಂದಿದೆ.  ಎಲ್ಲಾ ಹಾದುಹೋಗುವ ಮಾಡುತ್ತದೆ ವಸ್ತು ಈ ರೀತಿಯ ಕಾಣುವ ಒಂದು ಮದುವೆ ಸ್ಟ್ರಿಂಗ್ ನಿರ್ಮಿಸುತ್ತದೆ:

<sitecollection URL =’HTTP://demo2010a:9090′>
 
<ಬಲೆ
     ಶೀರ್ಷಿಕೆ = 'ಹಲೋ ವರ್ಲ್ಡ್ ಸ್ಯಾಂಡ್ಬಾಕ್ಸ್' 
     ಟೆಂಪ್ಲೇಟು = 'ಒಂದು ಸೈಟ್ ತಂಡಗಳಿಗೆ ತ್ವರಿತವಾಗಿ ಸಂಘಟಿಸಲು, ಲೇಖಕ, ಮತ್ತು ಮಾಹಿತಿಯನ್ನು ಹಂಚಿಕೊಳ್ಳಬೇಡಿ, BLAH BLAH BLAH '>

     <ಪಟ್ಟಿ
        ಶೀರ್ಷಿಕೆ = 'BCC_Health_Services_FAQs’
        Template=’CustomList’
       
listid=’HTTP://demo2010a:9090/helloworldsandbox[delim]1e02b001-3cb2-4f17-b63d-7809e86b4174′>
    
</ಪಟ್ಟಿ>

     <ಪಟ್ಟಿ
        title=’BCC_Notifications’ 
        Template=’CustomList’ 
        listid=’
HTTP://demo2010a:9090/helloworldsandbox[delim]5a5a13d1-877c-41c0-9063-b9612be80d5e’>
     </ಪಟ್ಟಿ>

  </ಬಲೆ>

</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