C# 树形视图和文本框

发布于 2024-10-04 15:36:38 字数 299 浏览 0 评论 0原文

我有一个非常简单的问题要问:

我有一个 C# 网页,左侧有一个树视图,右侧有九个文本框。

树视图由具有 9 列的 SQL 表的数千行填充。

目标: 单击树视图项目时,更新九个文本框并显示每个列的值。

最好的方法是什么? 我是否应该在临时数据表中获取页面加载的所有数据,并通过单击树视图查询 C# 数据表? 或者我应该在单击树视图项时向 sql 表发送一条 select 语句? 或者有更好的方法吗?

该解决方案将被超过 15 个用户使用,性能是一个关键因素。

谢谢,

调频

I have a very simple question to ask:

I have a C# webpage which has a treeview on the left hand side and nine text boxes on the right hand side.

Tree view is populated from thousands of rows of a sql table that has 9 columns.

The aim:
On click of a tree view item, update the nine text boxes and show each of the column's value.

What is the best way to do it?
Should I fetch all of the data on page load in a temporary data table and query the C# data table on click of a tree view?
Or should I send a select statement to the sql table on click of the tree view item?
Or is there a better way?

This solution will be used by over 15 users and performance is a key factor.

Thanks,

FM

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难以启齿的温柔 2024-10-11 15:36:38

如果应用程序的所有用户的树视图都相同,则

1- 在应用程序启动事件中,将数据填充到数据表中并存储在应用程序变量中。

2-使用上面创建的应用程序变量来查询存储在其中的数据表。

3-当您单击树视图中的节点时,通过查询存储的数据表来显示详细信息。

如果树视图不是特定于用户的,那么这种方法会很好地工作,通过这样做,您将获得性能优势,因为您最大限度地减少了数据库访问。

If the tree view is same for all the users of your application than

1- On your Application Start event , fill the data in a dataable and store in the Application Variable.

2- Use above created Application varaible to query the datatble stored into it.

3- When you click on a node in the treeview, show the details by querying stored datatable.

this appraoch would work well , if the treeview is not user-specific by doing so you will get the performance benefit as you minimized the database trips.

半暖夏伤 2024-10-11 15:36:38

我将使用 服务器缓存 来存储数据表。

树视图对于每个用户来说都是相同的,并且缓存保存对数据表等对象的应用程序范围的引用。

添加:

Cache["MyTreeviewDataTable"] = MyTreeviewDataTable;

检索:

DataTable MyTreeviewDataTable = (DataTable)Cache["MyTreeviewDataTable"];

更新:您还应该查看SqlDependencySqlCachDependency 数据更改时通知的类。

SQL Server (ADO.NET) 中的查询通知

I would use the Server Cache to store the DataTable.

The Treeview is the same for every user and the cache holds application-wide references on objects like a DataTable.

add:

Cache["MyTreeviewDataTable"] = MyTreeviewDataTable;

retrieve:

DataTable MyTreeviewDataTable = (DataTable)Cache["MyTreeviewDataTable"];

Update: You should also have a look at the SqlDependency and SqlCachDependency Classes to notify when data changes.

Query Notifications in SQL Server (ADO.NET)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文