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

Load Multiple ComboBoxes at the same time

1 Answer 83 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
ryan
Top achievements
Rank 1
ryan asked on 11 Feb 2009, 03:22 PM
When someone selects an item in a combobox, I need to conditionally load 5 comboboxes with the same list of information. 

In the examples I saw, I was able to get this to work with 1 however I'm trying to find a more efficient way to deal with this problem.  Each RadComboBox has an OnItemsRequested which is used to populate the items, how can I have all of the 5 comboboxes load the same list without populating the datatable for each request?  Is there a way to have all of the comboboxes use 1 event for OnItemsRequested and populate all of my comboboxes without seperate calls to the database to fill my datatable and do the binding?

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Feb 2009, 09:10 AM

Hi Ryan,

One suggestion is by using session and storing the table in the session, so that not required sepearte calls to database in order to populate the RadComboBox. Attach same ItemRequested event handler to all the RadComboBoxes.

CS:

 protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
    {  
        if (Session["ds"] == null)  
        {  
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SI EmployeesConnectionString"].ConnectionString);  
 
            DataSet ds = new DataSet();  
 
            SqlDataAdapter da = new SqlDataAdapter("select * from Employee", con);  
            da.Fill(ds);  
            Session["ds"] = ds.Tables[0];             
        }  
        RadComboBox rad = (RadComboBox)o;  
        rad.DataValueField = "ID";  
        rad.DataTextField = "Name";  
        rad.DataSource = Session["ds"];  
        rad.DataBind();  
    }  

ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" ToolTip="Please enter your title" Skin="WebBlue" Text="Title" OnItemsRequested="RadComboBox1_ItemsRequested" EnableLoadOnDemand="True">   
        </telerik:RadComboBox> 
 
         <telerik:RadComboBox ID="RadComboBox2" runat="server"           
         ToolTip="Please enter your title" Skin="WebBlue" Text="Title" OnItemsRequested="RadComboBox1_ItemsRequested" EnableLoadOnDemand="True">        
            <CollapseAnimation Duration="200" Type="OutQuint" />       
        </telerik:RadComboBox>       
       
</div><telerik:RadComboBox ID="RadComboBox3" runat="server"           
         ToolTip="Please enter your title" Skin="WebBlue" Text="Title" OnItemsRequested="RadComboBox1_ItemsRequested" EnableLoadOnDemand="True">        
   </telerik:RadComboBox>       
       
        <telerik:RadComboBox ID="RadComboBox4" runat="server"           
         ToolTip="Please enter your title" Skin="WebBlue" Text="Title" OnItemsRequested="RadComboBox1_ItemsRequested" EnableLoadOnDemand="True">        
        </telerik:RadComboBox>       
       
        <telerik:RadComboBox ID="RadComboBox5" runat="server"           
         ToolTip="Please enter your title" Skin="WebBlue" Text="Title" OnItemsRequested="RadComboBox1_ItemsRequested" EnableLoadOnDemand="True">        
        </telerik:RadComboBox>    
 

Thanks,
Princy.
Tags
ComboBox
Asked by
ryan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or