On ItemsRequested event - do not update other controls

2 posts, 0 answers
  1. Kaushal
    Kaushal avatar
    8 posts
    Member since:
    Mar 2012

    Posted 12 Jun 2012 Link to this post

    I have a combobox and it fires event onItemsRequested. In the code, I bring some class objects and convert them to table and bind with combobox. So far so good. but when the data returned is zero then I want to show error message on the screen that combobox is empty because of the errorr... I update the label (id = lblError) during the code i.e. lblError.Text = "blah bla blah...." but it does not get updated on the screeen. I have ajaxmanager on the aspx page and lblError is included under the ajax settings. so I basically I want to update the label during Combobox_ItemRequested event.

      RadComboBox rcb = (RadComboBox)sender;
     rcb.Text = string.Empty;
      rcb.ShowMoreResultsBox = false;
      rcb.BackColor = System.Drawing.Color.Empty;
     Employee[] lemployee = Employee.Search();
                                if (lemployee.Length == 0)
                                    lblError.Text = "No employee found";
                                    lblError.Text = "";
                                    DataTable dtable = new DataTable();
                                    DataRow orow;
                                    foreach (Employee oemp  in lEmployee)
                                        orow = dtable.NewRow();
                                        orow["empID"] = oemp.empId.ToString();
                                        orow["name"] = oemp.name.Trim();
                                        orow["Address"] = oemp.Address;
                                        orow["SortFlag"] = "2";
                                    rcb.DataSource = dtable;

  2. Kalina
    Kalina avatar
    918 posts

    Posted 18 Jun 2012 Link to this post

    Hi Kaushal,

    I am afraid that by design the ItemsRequested event handler can be used only for providing data to populate the RadComboBox with items and is not intended to be used for updating other controls.

    However you can use the RadComboBoxItemsRequestedEventArgs to provide a status message.
    Please take a look at this online demo and the GetStatusMessage method implementation there.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top