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

Sort items in LoadOnDemand

2 Answers 60 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Udi
Top achievements
Rank 1
Udi asked on 12 Nov 2010, 08:22 PM
Hello,

I was trying to sort items while LoadOnDemand property set to true.
I put the SortItems() method inside the ItemsRequested event handler and set the Sort="Ascending" but nothing happend.
do i miss something?

I would like to sort the items during i load on demand is true.

Thanks
Oren

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Nov 2010, 10:49 AM
Hello,
I have tried the similar scenario in my application and that worked for me.Please check with the following code and find what is missing.

C#:
protected void rcbProva_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
   {
       RadComboBox combo = (RadComboBox)o;
       combo.Items.Clear();
       SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["NorthwindConnectionString2"].ConnectionString);
       SqlCommand cmd = new SqlCommand("select EmployeeID,FirstName from Employees where FirstName LIKE '" + e.Text + "%'", con);
       SqlDataAdapter da = new SqlDataAdapter(cmd);
       DataTable dt = new DataTable();
       da.Fill(dt);
       con.Close();
       foreach (DataRow row in dt.Rows)
       {
           RadComboBoxItem item = new RadComboBoxItem(row["FirstName"].ToString());
           combo.Items.Add(item);
       }
       combo.Sort = RadComboBoxSort.Ascending;
       combo.SortItems();
   }
 
 Please paste your code if it doesn't help .

Thanks,
Princy.
0
Princy
Top achievements
Rank 2
answered on 15 Nov 2010, 10:50 AM
.
Tags
ComboBox
Asked by
Udi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or