带有自定义 TreeNode 的 ASP.NET 自定义 Treeview
我有一个关于 ASP.NET 3.5 Treeview 和 Treenodes 的问题。我想构建一个支持多状态复选框的 Treeivew。我实际上想要 4 种状态 - 选中、未选中、不确定(就像三态框 - 父级是三态,如果不是所有子级都被选中)和 NotAppicable(此复选框将是 X 并呈灰色)。我已经阅读了如何使用 Web 用户控件 (.ascx) 添加自定义用户控件,但它似乎不适用于覆盖 TreeNode 和 TreeView。我在 .xml 文件中显示静态数据,并且我非常喜欢将树视图绑定到数据源的功能。所以,如果可以的话,我宁愿继续使用这棵树。
所以我想我有几个问题:
如何覆盖树视图或树节点,并将其添加到网络表单中? (所以我仍然可以使用设计器?)我是否必须将它们构建到 .dll 中并以这种方式加载?或者我可以将 .cs 文件添加到我的项目中吗?
有人对如何更改树节点以处理检查状态有任何想法吗?
关于如何将我的自定义图像用于不同的检查状态有什么想法吗?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有第一个问题的答案 - 如何覆盖树视图或树节点,并将其添加到网络表单? (所以我仍然可以使用设计器?)我是否必须将它们构建到 .dll 中并以这种方式加载?或者我可以将 .cs 文件添加到我的项目中吗?
每个人可能都知道如何做到这一点,但这对我来说是新闻。将扩展类添加到命名空间中的 App_Code 文件夹中:
然后,在以下 web.config 文件中包含对该命名空间的引用:
然后在 .aspx 文件中调用您的控件:
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: