Radcombox -There was error in callback

8 posts, 0 answers
  1. Naga
    Naga avatar
    11 posts
    Member since:
    Jul 2013

    Posted 25 Dec 2013 Link to this post

    Dynamically created ComboBox and Load-on-demand not working .
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Dec 2013 Link to this post

    Hi Naga,

    Please have a look into the following C# code snippet which works fine at my end.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        Telerik.Web.UI.RadComboBox combo =new Telerik.Web.UI.RadComboBox();
        combo.ID = "RadComboBox1";
        combo.AutoPostBack = true;
        combo.EmptyMessage = "Select";
        combo.EnableLoadOnDemand = true;
        combo.ItemsRequested += new Telerik.Web.UI.RadComboBoxItemsRequestedEventHandler(combo_ItemsRequested);
        form1.Controls.Add(combo);
    }
    void combo_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
    {
        Telerik.Web.UI.RadComboBox combo = (Telerik.Web.UI.RadComboBox)sender;
        String connstring = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(connstring);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand("SELECT Cityname from City ", conn);
        DataTable data = new DataTable();
        conn.Open();
        try
        {
            adapter.Fill(data);
            combo.DataSource = data;
            combo.DataTextField = "Cityname";
            combo.DataBind();
        }
        finally
        {
            conn.Close();
        }
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Naga
    Naga avatar
    11 posts
    Member since:
    Jul 2013

    Posted 01 Jan 2014 Link to this post

    Static radcombox load on demand is working fine,Dynamic Rad combobox load on demand not working.
    We are using telerik(2013.3.1114.45)version in visual studio 2012.

    Dynamic Rad combobox load on demand time,Iam getting "There was error in callback" this error.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jan 2014 Link to this post

    Hi Naga,

    Please have a look into the following forum thread which deals the same issue. Please provide your code if it doesn't help.

    Load On Demand and Exception handling.
    Server Error in the ItemRequest Event.

    Thanks,
    Shinu.

  6. Naga
    Naga avatar
    11 posts
    Member since:
    Jul 2013

    Posted 02 Jan 2014 Link to this post



    Hi Shinu,



              Please check error .verify the below mentioned code also.



    public void InstantiateIn(System.Web.UI.Control container)
                {

                    combo = new RadComboBox();
                    combo.ID = colname;

                    combo.AutoPostBack = true;
                    combo.AppendDataBoundItems = true;
                    combo.AllowCustomText = true;
                    combo.CheckBoxes = true;
                    combo.AutoPostBack = true;
                    combo.EnableCheckAllItemsCheckBox = true;

                    combo.CheckedItemsTexts = RadComboBoxCheckedItemsTexts.DisplayAllInInput;
                    combo.MarkFirstMatch = true;
                    combo.HighlightTemplatedItems = true;
                    combo.EmptyMessage = "All";
                    combo.NoWrap = false;
                    combo.CssClass = "target-users-popup-dropdown";
                    combo.DropDownCssClass = "target-users-popup-dropdown-1";
                    combo.Localization.AllItemsCheckedString = "All";
                    combo.Localization.CheckAllString = "All";
                    combo.OnClientDropDownClosing = "ShowModalPopup";
                    combo.PreRender += new EventHandler(combo_PreRender);
                    combo.EnableLoadOnDemand = true;
                   combo.ShowMoreResultsBox = true;
                     combo.ItemsPerRequest=10;
                     combo.EnableVirtualScrolling = true;
                    combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(l_SelectedIndexChanged);
                    combo.ItemDataBound += new RadComboBoxItemEventHandler(combo_ItemDataBound);
                   combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(combo_ItemsRequested);
                    combo.DataValueField = colname;
                    combo.DataTextField = colname;
                    combo.DataBind();
                    container.Controls.Add(combo);

                }

                void combo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
                {
                    int ItemsPerRequest = 10;

                    RadComboBox combo = (RadComboBox)sender;
                    if (combo != null)
                    {

                        int itemOffset = e.NumberOfItems;
                 );
                        List<string> data = GetUserProfieColumnData(combo.DataValueField, itemOffset, ItemsPerRequest);

                        e.EndOfItems = ItemsPerRequest > data.Count;

                        for (int i = 0; i < data.Count; i++)
                        {
                                            combo.Items.Add(new RadComboBoxItem(data[i].ToString(), data[i].ToString()));

                        }

                      
                        obj.ComboPrerender(sender, e);

                    }
                }

  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jan 2014 Link to this post

    Hi  Naga,

    Please try the following code snippet which works fine at my end.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        Telerik.Web.UI.RadComboBox combo;
        string colname = "CompanyName";
        combo = new RadComboBox();
        combo.ID = colname;
     
        combo.AutoPostBack = true;
        combo.AppendDataBoundItems = true;
        combo.AllowCustomText = true;
        combo.CheckBoxes = true;
        combo.AutoPostBack = true;
        combo.EnableCheckAllItemsCheckBox = true;
     
        combo.CheckedItemsTexts = RadComboBoxCheckedItemsTexts.DisplayAllInInput;
        combo.MarkFirstMatch = true;
        combo.HighlightTemplatedItems = true;
        combo.EmptyMessage = "All";
        combo.NoWrap = false;
        combo.CssClass = "target-users-popup-dropdown";
        combo.DropDownCssClass = "target-users-popup-dropdown-1";
        combo.Localization.AllItemsCheckedString = "All";
        combo.Localization.CheckAllString = "All";
        combo.EnableLoadOnDemand = true;
        combo.ShowMoreResultsBox = true;
        combo.ItemsPerRequest = 10;
        combo.EnableVirtualScrolling = true;
        combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(combo_ItemsRequested);
        combo.DataValueField = colname;
        combo.DataTextField = colname;
        combo.DataBind();
        form1.Controls.Add(combo);
    }
    void combo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        RadComboBox combo = (RadComboBox)sender;
        DataTable data = GetData(e.Text);
        int itemOffset = e.NumberOfItems;
        int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
        e.EndOfItems = endOffset == data.Rows.Count;
     
        for (int i = itemOffset; i < endOffset; i++)
        {
            combo.Items.Add(new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString(), data.Rows[i]["CompanyName"].ToString()));
        }
        e.Message = GetStatusMessage(endOffset, data.Rows.Count);
    }
    private static DataTable GetData(string text)
    {
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from Customers ", ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        DataTable data = new DataTable();
        adapter.Fill(data);
        return data;
    }
    private static string GetStatusMessage(int offset, int total)
    {
        if (total <= 0)
            return "No matches";
        return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
    }

    Hope this will helps you.
    Thanks,
    Shinu.
  8. Naga
    Naga avatar
    11 posts
    Member since:
    Jul 2013

    Posted 03 Jan 2014 Link to this post

    What is the difference in code?

  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jan 2014 Link to this post

    Hi Naga,

    In my code OnItemRequestedEvent I am trying to access all the data from the table and adding items to the RadComboBox based on the current itemoffset and endoffset values. So first it will add only 10 items to the RadComboBox and then from 10 to 20 items and so on. The GetStatusMessage is used to display the status of the RadComboBoxItems.

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017