如何提高在DevExpress中使用7500行填充组合框的查询性能?

时间:2015-03-11 08:16:26

标签: sql-server devexpress

我有一个DevEx GridView,里面有GridViewDataComboBoxColumn。我需要用7500行填充组合框。我在存储过程sp_select_AllStocks

中使用了以下查询
Select StockId,StockName from StockMaster;

以下代码在aspx.cs页面中用于动态绑定组合框。

DataTable dt_fill_StocksCombo = new DataTable();
            dt_fill_StocksCombo = con.select_AllStocks();
            ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.IncrementalFilteringMode = DevExpress.Web.ASPxEditors.IncrementalFilteringMode.StartsWith;
            ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDown;
            ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.DataSource = dt_fill_StocksCombo;
            ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.ValueField = "StockId";
            ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.TextField = "StockName";

select_AllStocks()的函数定义如下。

public DataTable select_AllStocks()
    {
        Open_Connection();
        DataTable dt = new DataTable();
        cmd = new SqlCommand("sp_select_AllStocks", con);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter adt = new SqlDataAdapter(cmd);
        adt.Fill(dt);
        Close_Connection();
        return dt;
    }

上述方法需要大约30秒才能将组合框加载到7500行。 有没有办法提高性能?

2 个答案:

答案 0 :(得分:0)

ComboBox支持根据需要从数据库中提取记录。 ASPxComboBox.ItemsRequestedByFilterConditionASPxComboBox.ItemRequestedByValue事件用于此目的。请参阅Filtering a Large Data Source演示。以下是如何在网格中使用此功能的解决方案:ASPxGridView - Filtering a Large Data Source in a combobox

答案 1 :(得分:0)

Public Sub fillCombo(ByVal cbobox As LookUpEdit)         用cbobox             cbobox.Properties.Columns.Clear()             cbobox.Properties.Columns.Add(New LookUpColumnInfo(" Code",10))             cbobox.Properties.Columns.Add(New LookUpColumnInfo(" Name",20))             .Properties.Columns.Item(0).Visible = False

        ds = INVBl.FillCustomer()
        .Properties.DataSource = ds.Tables(0)
        .Properties.DisplayMember = "Name"
        .Properties.ValueMember = "Code"
        .Properties.ShowFooter = False
        .Properties.ShowHeader = False
        .Properties.ShowLines = False
    End With
End Sub


Public Sub RfillCombo(ByVal cbobox As Repository.RepositoryItemLookUpEdit, ByVal column As String)
    With cbobox
        cbobox.Properties.Columns.Clear()
        cbobox.Properties.Columns.Add(New LookUpColumnInfo("Code", 10))
        cbobox.Properties.Columns.Add(New LookUpColumnInfo("Name", 20))
        .Properties.Columns.Item(0).Visible = False

        ds = INVBl.FillItem(column)
        .Properties.DataSource = ds.Tables(0)
        .Properties.DisplayMember = "Name"
        .Properties.ValueMember = "Code"
        .Properties.ShowFooter = False
        .Properties.ShowHeader = False
        .Properties.ShowLines = False
    End With
End Sub