gpt4 book ai didi

c# - 将大量数据绑定(bind)到组合框?

转载 作者:可可西里 更新时间:2023-11-01 08:23:24 25 4
gpt4 key购买 nike

我想在下拉列表中绑定(bind)员工列表,具有自动完成功能,以便用户可以搜索正确的名称。我使用 RadComboBox

我有两个主要问题:

1- 列表非常大,大约有 5000 项。因此在浏览器中绑定(bind)如此大量的数据会使它挂起或变慢。(性能问题)

根据 Telerik 文档

Set a data source to the RadComboBox. Use either DataSourceID or the DataSource property to do this and set the DataTextField and DataValueField properties to the respective fields in the data source. (Note that when using DataSource you must set the property on each postback, most conveniently in Page_Init.) Set EnableAutomaticLoadOnDemand to true.

所以每次在Page_Init中我都必须调用下面的方法!!!

  protected void BindInnerInstructors()
{
ddl_inner_sup.Items.Clear();
ddl_inner_sup.DataSource = Utilities.GetAllInnerInstructors();
ddl_inner_sup.DataValueField = "emp_num";
ddl_inner_sup.DataTextField = "name";
ddl_inner_sup.DataBind();
}

2- 尝试设置组合框的选择时,对象引用未设置到对象的实例。

我通过 this 克服了这个问题.


我有大约 4 个下拉列表,但每个列表都必须根据事件绑定(bind),但我必须在 page_init 中绑定(bind)所有这些列表。

如果能详细回答这个问题,我将不胜感激。

最佳答案

我的公司有类似的问题。我们最终使用了一个名为 Select2 的 jquery 对象,我们延迟加载了列表。基本上我们在加载时只加载前 10 个左右,这样可以快速加载,如果用户向下滚动超过前 10 个,我们加载下 10 个,依此类推。 Select2 有一个搜索功能,它会点击服务器以返回基于搜索的自定义列表。

一次加载 5000 个元素的问题在于,浏览器将花费很长时间来加载它们、遍历它们并根据需要操作它们。我并不是说“你必须使用 select2”,RadComboBox 可能有这样的东西你可以使用。

祝你好运。

关于c# - 将大量数据绑定(bind)到组合框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16759819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com