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

On ItemsRequested event - do not update other controls

1 Answer 46 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kaushal
Top achievements
Rank 1
Kaushal asked on 12 Jun 2012, 07:59 PM
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.ClearSelection();
 rcb.Text = string.Empty;
  rcb.Items.Clear();
  rcb.ShowMoreResultsBox = false;
  rcb.BackColor = System.Drawing.Color.Empty;
  
 Employee[] lemployee = Employee.Search();
  
                            if (lemployee.Length == 0)
                            {
                                lblError.Text = "No employee found";
                                return;
                            }
                            else
                            {
                                lblError.Text = "";
                                 
                                DataTable dtable = new DataTable();
                                DataRow orow;
  
                                dtable.Columns.Add("empID");
                                dtable.Columns.Add("name");
                                dtable.Columns.Add("SortFlag");
                                dtable.Columns.Add("Address");
  
                                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";
  
                                    dtable.Rows.Add(orow);
                                }
  
                                rcb.DataSource = dtable;
                                rcb.DataBind();
}


1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 18 Jun 2012, 02:21 PM
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.

Regards,
Kalina
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.
Tags
ComboBox
Asked by
Kaushal
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or