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