如何将 AJAX 树视图转换为链接按钮?
我需要一些有关将 AJAX TreeView
控件转换为 LinkButton
的建议。 为什么?让ASP.NET页面变得更轻量。目前,当选择TreeView
的Nodes
时,与该节点相关的记录将显示在网格中。这种实现使页面变得很重。因此我们决定将其更改为 LinkButtons
。
我只是想知道我需要做、考虑哪些事情,或者这是一个好主意吗?老实说,无论这是好还是坏主意,我仍然需要这样做。
我最初的理解是,这将像一个列表例如:项目符号列表
。
I need some advice regarding conversion of an AJAX TreeView
control to a LinkButton
.
Why? To make the ASP.NET page lighter. Currently, when the Nodes
of the TreeView
is selected, records related to that node are displayed in a grid. This implementation makes the page heavy. So we decided to changed this to LinkButtons
.
I just want know what are the things I need to do, consider, or is this a good idea? Honestly, whether this is a good or bad idea, I still need to do this.
My initial understanding is that this will turn out like a list ex: bullet list
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下答案基于您的评论,并基于 您的其他问题。
以下示例使用 ListView 而不是 Repeater。 ListView 很棒,因为它们比 Repeater 具有更大的灵活性。此外,正如您在下面的示例代码中看到的,绑定嵌套/子 ListView 和绑定嵌套/孙 ListView 都可以以声明方式完成,无需任何隐藏代码。
以下代码生成的示例
ASPX
C#
如您所见,在 C# 代码中,我创建了一个“Person”列表,如下所示。每个 Person 对象都有一个子 Person 对象列表,每个子 Person 对象都有一个子 Person 对象列表。通过以这种方式创建对象,绑定 ListView 实际上就像我所展示的一样简单。使用下面的 Person 对象运行一个快速示例,以便您亲自查看。
Person 对象
对于您的测试,您可以创建一个 Page_Load 方法,如下所示:
请参阅以下 StackOverflow 问题以了解有关 Repeater 和 ListView 之间差异的更多信息:Repeater、ListView、DataList、DataGrid、GridView ... 选择哪个?
The following answer is based on your comment and builds on the answer provided in your other question.
The following example uses a ListView instead of a Repeater. ListViews are great because they'll give you much more flexibility over a Repeater. Moreover, as you can see in the sample code below, binding the nested/child ListView and binding the nested/grandchild ListView can all be done declaratively without any code-behind.
Example of what the following code will produce
ASPX
C#
As you can see, in the C# code, I've created a list of "Person" as follows. Each Person object has a list of child Person objects and aach child Person object has a list of child Person objects. By creating your objects in this manner, binding the ListView is really as simple as I've shown. Use the Person object below to run a quick sample so you can see for yourself.
Person object
For your test, you can create a Page_Load method as follows:
See the following StackOverflow question to learn more about the differences between a Repeater and a ListView: Repeater, ListView, DataList, DataGrid, GridView ... Which to choose?