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

RadComboBox events not firing

3 Answers 164 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 10 Dec 2008, 07:18 AM

I'm trying to get the RadComboBox to work. I've downloaded the "Paging in RadComboBox' Load On Demand" example from http://www.telerik.com/community/code-library/aspnet-ajax/combobox/paging-in-radcombobox-load-on-demand.aspx, which works fine.

Now I want do duplicate this functionality, however I can't seem to get it working (for some reason no client or server events are firing), so I've downloaded the RadControlsAJAXCourseware.pdf courseware to follow the guide step-by-step but onn page 368 step 3 it asks for a folder "\VS Projects\Images\Colors" which I cannot find; there is no folder like this on my system.

I have installed "RadControls 'Prometheus' for ASPNET Q3 2007". Can you point me in the right direction as to any possible reasons why my events don't fire and/or this Colors folder? I'm assumming there will be a simple solution, but for the life of me I can't find it !?!

Thanks.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script language="javascript" type="text/javascript">  
            function comboContact_OnClientItemsRequesting(sender, eventArgs)  
            {         
                var context = eventArgs.get_context();    
                context["ContactType"] = "xxx";  
            }  
 
        </script> 
    </telerik:RadCodeBlock> 
 
    <form id="form1" runat="server">  
    <div> 
      
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
        </telerik:RadScriptManager> 
          
        <telerik:RadComboBox ID="comboContact" runat="server" EnableLoadOnDemand="true" OnClientItemsRequesting="comboContact_OnClientItemsRequesting" OnItemsRequested="comboContact_ItemsRequested" ShowDropDownOnTextboxClick="False" 
            ShowToggleImage="True" ItemRequestTimeout="1500" AppendDataBoundItems="True" ShowWhileLoading="False" AutoPostBack="True" > 
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                <ExpandAnimation Type="OutQuart" /> 
                <ItemTemplate> 
                    <table style="width: 250px; text-align: left">  
                        <tr> 
                            <td style="width: 100px;">  
                                <%# DataBinder.Eval(Container.DataItem, "FirstName") %> 
                            </td> 
                        </tr> 
                    </table> 
                  
                </ItemTemplate> 
                <HeaderTemplate> 
                    <table style="width: 250px; text-align: left">  
                        <tr> 
                            <td style="width: 100px;">  
                                FirstName  
                            </td> 
                        </tr> 
                    </table>                               
                </HeaderTemplate> 
        </telerik:RadComboBox> 
          
    </div> 
    </form> 
</body> 
</html> 
 
using System;  
using System.Data;  
using System.Configuration;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using System.Data.SqlClient;  
using Telerik.Web.UI;  
 
public partial class _Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
    }  
 
    private DataSet GetAllContacts()  
    {  
        DataSet retVal = null;  
 
        try  
        {  
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mainConnectionString"].ConnectionString))  
            {  
                SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Contact ORDER BY FirstName", conn);  
                DataSet ds = new DataSet();  
                da.Fill(ds);  
 
                retVal = ds;  
            }  
        }  
        catch (SqlException ex)  
        {  
 
        }  
 
        return retVal;  
    }  
 
    protected void comboContact_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
    {  
        //get a ref to the calling combo  
        RadComboBox combo = (RadComboBox)o;  
        string thePasedString = e.Context["ContactType"].ToString();        // /thePasedString/ should = "xxx", right?  
 
        combo.ClearSelection();  
 
        combo.DataSource = GetAllContacts();  
        combo.DataValueField = "ContactID";  
        combo.DataTextField = "FirstName";  
        combo.DataBind();  
    }  
 
}  
 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2008, 12:45 PM
Hi Brad,

I tried with your code on my end and it working as expected. ItemRequested event fires when the user types text into the input field or clicks on the drop-down toggle image when the list is empty.

ASPX:
 <telerik:RadComboBox ID="RadComboBox1" runat="server"  EnableLoadOnDemand="true" AutoPostBack="True" OnItemsRequested="RadComboBox1_ItemsRequested" > 
        
            </telerik:RadComboBox> 

CS:
protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) 
    { 
        RadComboBox1.DataSource = GetAllContacts(); 
        RadComboBox1.DataValueField = "ProductName"
        RadComboBox1.DataTextField = "ProductName"
        RadComboBox1.DataBind();  
        
         
    } 
    private DataSet GetAllContacts() 
    { 
        DataSet retVal = null
 
         
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthWindConnectionString"].ConnectionString)) 
            { 
                SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Products", conn); 
                DataSet ds = new DataSet(); 
                da.Fill(ds); 
 
                retVal = ds
            } 
         
         
 
        return retVal; 
    } 

One another suggestion will be to replace RadScriptManager with ScriptManager and see if the ItemRequested event is getting fired.

Thanks
Shinu
0
Brad
Top achievements
Rank 1
answered on 10 Dec 2008, 01:05 PM
Eh? Can you confirm that you're using "RadControls 'Prometheus' for ASPNET Q3 2007" :
File Description: Telerik.Web.UI
File Version: 2007.3.1314.20

of the Telerik.Web.UI.dll file ?
I'm using Vista with Visual Studio 2005. If this code is working for you as you say, can you suggest as to why the event isn't firing? Is there some other setting (maybe some project global or system setting?) that I'm missing? How can I check this?

 

Brad.

 

0
Shinu
Top achievements
Rank 2
answered on 11 Dec 2008, 06:47 AM
Hi Brad,

I am using RadControls for asp.net AJAX(2008.3.1125.20). I am not sure whether some other settings is needed. Try upgrading to the latest version of the RadControls and see if it is working.

Shinu

Tags
ComboBox
Asked by
Brad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Brad
Top achievements
Rank 1
Share this question
or