I have a question regarding the ASP.NET 3.5 Treeview and Treenodes. I’d like to build a Treeivew that supports multistate checkbox. I actually would like 4 states – checked, unchecked, indeterminate (like a tri-state box – parent is tri-state, if not all of the children are checked) and NotAppicable (this checkbox would be an X and greyed out). I’ve read up on how to add custom user controls, by using a Web User Control (.ascx), but it doesn’t seem to work that way for overriding the TreeNode and TreeView. I am showing static data in an .xml file, and I really like the capability of binding the treeview to a datasource. So, I’d prefer to continue using the tree if I can.
So I guess I have a few questions:
-
How do I override the treeview or treenode, and add it to a webform? (So I can still use the designer?) Do I have to build them into a .dll and load that way? Or can I add .cs files to my project?
-
Does anyone have any ideas on how to change the treeNode to handle checkstates?
-
Any ideas on how to use my custom images for the different check states?
Thanks!
I have an answer to my 1st question – How do I override the treeview or treenode, and add it to a webform? (So I can still use the designer?) Do I have to build them into a .dll and load that way? Or can I add .cs files to my project?
Everyone might know how to do this, but it was news to me. Add the extended classes to the App_Code folder in a namespace:
Then, include a reference to that namespace int the web.config file under:
and then call your control in the .aspx file: