This is a migrated thread and some comments may be shown as answers.

[Solved] ComboBox and a lot of data

0 Answers 79 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Erik Hansen
Top achievements
Rank 1
Erik Hansen asked on 23 Feb 2010, 12:25 PM

I need help. I don’t know if I'm on the right track or if there is a better way to select a value from a foreign table.
I have 77.000 records in my foreign table and it creates loading problem when I open my EditForm.

I use an ObjectDataSource

<asp:ObjectDataSource ID="DS_All" runat="server" SelectMethod="getAll" 
    TypeName="CRSUsing+CRSData" > 
</asp:ObjectDataSource> 
 


The code behind looks like this

public class loopUpData 
    string Id; 
    string Txt; 
 
    public String id 
    { 
        get { return Id; } 
        set { Id = value; } 
    } 
 
    public String txt 
    { 
        get { return Txt; } 
        set { Txt = value; } 
    } 
public ICollection getSagsbudgetAll() 
    SqlConnection myConnection; 
    ArrayList LookUplist = new ArrayList(); 
 
    myConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SubjectConnect"].ToString()); 
 
    SqlCommand myCommand = new SqlCommand( 
        @"SELECT   distinct CAST(ID AS VARCHAR) as Id,  
                   (CAST(Id AS VARCHAR) + '  ' + Name) as Txt 
          FROM     s_dim  
          ORDER BY Id", myConnection); 
 
    myConnection.Open(); 
    SqlDataReader reader = myCommand.ExecuteReader(); 
 
    while (reader.Read()) 
    { 
        loopUpData lookUp = new loopUpData(); 
 
        lookUp.id = (string)reader["Id"]; 
        lookUp.txt = (string)reader["Txt"]; 
 
        LookUplist.Add(lookUp); 
    } 
 
    myConnection.Close(); 
    reader.Close(); 
    myCommand.Dispose(); 
 
    if (LookUplist != null && LookUplist.Count > 0) 
        return LookUplist; 
    else return null; 
 
 

In my EditForm I have placed a ComoBox.
<telerik:RadComboBox ID="Box1" AppendDataBoundItems="true" runat="server" DataSourceID="DS_All" 
    Width="300px" DataTextField="Txt" DataValueField="Id" AutoPostBack="True" 
    EnableVirtualScrolling="true" TabIndex="1" EnableLoadOnDemand="true" 
    ShowMoreResultsBox="true"  
    SelectedValue='<%# DataBinder.Eval(Container, "DataItem.Value") %>' 
    ReadOnly='<%# DataItem is GridInsertionObject %>' Skin="Office2007" > 
</telerik:RadComboBox> 
 


Any Ideas on how to do this?
Thanks
Erik


No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Erik Hansen
Top achievements
Rank 1
Share this question
or