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

[Solved] RadComboBox ItemsRequested Problem

3 Answers 154 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
ratan mishra
Top achievements
Rank 1
ratan mishra asked on 11 Dec 2009, 02:38 PM
Hi all,

Here in the combobox i am getting problem with ItemsRequested event i am unable to get related data of which the word i had typed in the RadComboBox here is the code

protected void cmbPlatformName_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){DataTable data = objTaskmanLib.GetData(e.Text); //GetData(e.Text);RadComboBoxItem item = new RadComboBoxItem();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++){cmbPlatformName.Items.Add(new RadComboBoxItem(data.Rows[i]["Platform_Name"].ToString(), data.Rows[i]["Platform_Name"].ToString()));}e.Message = GetStatusMessage(endOffset, data.Rows.Count);}private string GetStatusMessage(int endOffset, int total){if (total <= 0)return "No matches";return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, total);}

Here is the library code of getdata()

 public DataTable GetData(string text)
        {
            DataTable data = new DataTable();
            //data = null;
            try
            {
                conn = new SqlConnection(connectionstring);
                SqlDataAdapter adapter = new SqlDataAdapter("Select Platform_ID, Platform_Name from T26_Platform_Main where Record_Status='Active' and Platform_Name LIKE '" + text + "%'", connectionstring);
                //adapter.SelectCommand.Parameters.AddWithValue("@text", text);
                //SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from T26_Platform_Main WHERE Platform_Name LIKE @text + '%'",ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
                adapter.Fill(data);
                //return data;
            }
            catch (Exception excep)
            { 
                Console.WriteLine(excep.Message); 
            }
            return data;  
        }

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 11 Dec 2009, 03:05 PM
Hi ratan mishra,

What is e.Text returning in the ItemsRequested event handler? Isn't it the text that has just been typed in the input on the client side?

Regards,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
ratan mishra
Top achievements
Rank 1
answered on 12 Dec 2009, 04:41 AM
Hi simon,

Thanks for the reply ya (e.text) is the text that has been entered in the RadComboBox at clientside.

Thanks in Advance.
0
Simon
Telerik team
answered on 15 Dec 2009, 12:17 PM
Hello ratan mishra,

In this case then, you have the Text that has been typed in the input of the RadComboBox. 

Why cannot you use it to get related data? Can you please clarify what do you mean by the statement below so that I have a better idea of your issue and eventually provide guidance?

"[...]i am unable to get related data of which the word i had typed in the RadComboBox[...]"

All the best,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
ratan mishra
Top achievements
Rank 1
Answers by
Simon
Telerik team
ratan mishra
Top achievements
Rank 1
Share this question
or