using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.IO;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Configuration;

namespace Telerik.ComboboxExamplesCS.MultiColumnCombo
{
	public partial class DefaultCS:Page
	{
       

		protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
		{		
			string sql = "SELECT * from Customers WHERE CompanyName LIKE '" + e.Text + "%'";
			SqlDataAdapter adapter = new SqlDataAdapter(sql,
				ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);

			DataTable dt = new DataTable();
			adapter.Fill(dt);
			
			RadComboBox comboBox = (RadComboBox)sender;

			RadComboBox1.DataSourceID = "";
			RadComboBox1.DataSource = dt;
            RadComboBox1.DataBind();
		}

		protected void Button1_Click(object sender, System.EventArgs e)
		{
			Label1.Text = "You selected: <b>" + RadComboBox1.SelectedValue + "</b>";
		}

		protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
		{
            e.Item.Text = ((DataRowView)e.Item.DataItem)["CompanyName"].ToString(); 
            e.Item.Value = ((DataRowView)e.Item.DataItem)["City"].ToString();
        }

	}
}
