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.WebControls;
using System.Data.OleDb;

public partial class ComboStreamer : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    override protected void OnInit(EventArgs e)
    {
        InitializeComponent();
        base.OnInit(e);
    }

    private void InitializeComponent()
    {
        this.RadComboBox1.ItemsRequested += new Telerik.WebControls.RadComboBoxItemsRequestedEventHandler(this.RadComboBox1_ItemsRequested);
        this.Load += new System.EventHandler(this.Page_Load);

    }

    private void RadComboBox1_ItemsRequested(object o, Telerik.WebControls.RadComboBoxItemsRequestedEventArgs e)
    {
        RadComboBox1.Items.Clear();

        string mdbPath = Server.MapPath("~/App_Data/NWind.mdb");
        OleDbConnection dbCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath);
        dbCon.Open();

        string text = e.Text;
        string sql = "SELECT ContactName from Customers WHERE ContactName LIKE '" + text + "%'";

        OleDbDataAdapter adapter = new OleDbDataAdapter(sql, dbCon);
        DataTable dt = new DataTable();
        adapter.Fill(dt);
        dbCon.Close();

        foreach (DataRow row in dt.Rows)
        {
            RadComboBoxItem item = new RadComboBoxItem(row["ContactName"].ToString());
            item.Value = row["ContactName"].ToString();
            RadComboBox1.Items.Add(item);
        }
    }
}
