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

[Solved] AutoComplete and Loadondemand not working in radcombobox

3 Answers 217 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Leadeng Leadeng
Top achievements
Rank 1
Leadeng Leadeng asked on 25 Sep 2009, 08:25 PM
Dear Telerik
                      I am working with RadCombobox of telerik and I want it to display autocomplete and loadondemand.when I type a character it is showing me loading... but not displaying anything.Please let me know what is wrong in this code.Please reply as it is urgent for us to deliver.
Aspx page code

<%

@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="webTest._Default" %>

 

<%

@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

 

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<

html xmlns="http://www.w3.org/1999/xhtml" >

 

<

head runat="server">

 

 

<title>Untitled Page</title>

 

 

</

head>

 

<

body>

 

 

<form id="form1" runat="server">

 

 

<div>

 

 

<telerik:RadScriptManager ID="rsm" runat="server"></telerik:RadScriptManager>

 

 

<telerik:RadComboBox ID="RadComboBox1" runat="server"

 

 

Height="190px"

 

 

Width="420px"

 

 

MarkFirstMatch="true"

 

 

AllowCustomText="true"

 

 

EnableLoadOnDemand="true"

 

 

HighlightTemplatedItems="true"

 

 

DropDownWidth="423px"

 

 

 

ItemRequestTimeout="500" OnItemDataBound="RadComboBox1_ItemDataBound" OnItemsRequested="RadComboBox1_ItemsRequested" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">

 

 

<headertemplate>

 

 

<table style="width:415px; text-align:left">

 

 

<tr>

 

 

<td style="width:125px;">

 

Id

 

</td>

 

 

<td style="width:125px;">

 

Name

</td>

 

 

</tr>

 

 

</table>

 

 

</headertemplate>

 

 

<ItemTemplate>

 

 

<table style="width:415px; text-align:left">

 

 

<tr>

 

 

<td style="width:125px;">

 

<%

# DataBinder.Eval(Container.DataItem, "Id") %>

 

 

</td>

 

 

<td style="width:125px;">

 

<%

# DataBinder.Eval(Container.DataItem, "Name") %>

 

 

</td>

 

 

</ItemTemplate>

 

 

</

telerik:RadComboBox>

 

 

</div>

 

 

 

 

</form>

 

</

body>

 

</

html>

 


Code Behind File Code

using

System;

 

using

System.Data;

 

using

System.Configuration;

 

using

System.Collections;

 

using

System.Web;

 

using

System.Web.Security;

 

using

System.Web.UI;

 

using

System.Web.UI.WebControls;

 

using

System.Web.UI.WebControls.WebParts;

 

using

System.Web.UI.HtmlControls;

 

using

Telerik.Web.UI;

 

using

Telerik.Web.Design;

 

using

System.Data.OleDb;

 

using

System.Text;

 

using

System.IO;

 

namespace

webTest

 

{

 

public partial class _Default : System.Web.UI.Page

 

{

 

OleDbConnection cn;

 

 

OleDbDataAdapter da;

 

 

DataSet ds;

 

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

if (!Page.IsPostBack && !Page.IsCallback)

 

{

Load1(

string.Empty);

 

}

}

 

public void Load1(string filter)

 

{

 

string sql = "select * from emp1234";

 

cn =

new OleDbConnection("Provider=OraOLEDB.Oracle;Data Source=D1;User ID=SC;Password=D1;Connection Lifetime=600;Max Pool Size=100");

 

cn.Open();

sql +=

" where Name LIKE '" + filter.Replace("'","''") + "%'";

 

Response.Write(sql);

da =

new OleDbDataAdapter(sql, cn);

 

ds =

new DataSet();

 

da.Fill(ds);

cn.Close();

 

DataView dv = new DataView(ds.Tables[0]);

 

RadComboBox1.DataSource = dv;

RadComboBox1.DataBind();

}

 

 

protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)

 

{

Load1(e.Text);

}

 

protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)

 

{

 

RadComboBoxItem item = e.Item;

 

 

DataRowView drv = (DataRowView)e.Item.DataItem;

 

e.Item.Text = drv[

"Name"].ToString();

 

 

}

 

protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)

 

{

 

}

 

}

}




Thanks and Regards
Sri

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 26 Sep 2009, 11:15 AM
Hello Leadeng,

When you put a breakpoint in the ItemsRequested event of the combobox - does it get hit? If yes, please check if the Load1 method correctly retrieves the items from the database.

Let us know

Kind regards,
Veselin Vasilev
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
Leadeng Leadeng
Top achievements
Rank 1
answered on 28 Sep 2009, 02:11 PM
Dear Admin
                       

               Question: When you put a breakpoint in the ItemsRequested event of the combobox - does it get hit? 
               Answer:Yes
               Load method is retrieving the data correctly.all the records are getting displayed.But when a character is typed and
               the control displays loading... .  .autocomplete and loadondemand  it seems to me are not working.Please let me know
               what is wrong with the code.
Thanks and Regards
Sri

0
Veselin Vasilev
Telerik team
answered on 29 Sep 2009, 05:31 AM
Hi Leadeng Leadeng,

Maybe you are facing the problem described here. Please try with the latest internal build and let us know.

Best wishes,
Veselin Vasilev
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
Leadeng Leadeng
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Leadeng Leadeng
Top achievements
Rank 1
Share this question
or