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 System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class WebUserControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindCombo();
        }
        //BindToDataTable(RadComboBox1);
    }

    protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        //string sql = "SELECT * from Employees";

        //SqlDataAdapter adapter = new SqlDataAdapter(sql,
        //ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        //string sql = "SELECT * from LargeOrderDetails";
        //SqlDataAdapter adapter = new SqlDataAdapter(sql,
        //    ConfigurationManager.ConnectionStrings["TelerikConnectionString"].ConnectionString);
        
        //DataTable data = new DataTable();
        //adapter.Fill(data);

        //try
        //{
        //    int itemsPerRequest = 250;
        //    int itemOffset = e.NumberOfItems;
        //    int endOffset = itemOffset + itemsPerRequest;
        //    if (endOffset > data.Rows.Count)
        //    {
        //        endOffset = data.Rows.Count;
        //    }
        //    if (endOffset == data.Rows.Count)
        //    {
        //        e.EndOfItems = true;
        //    }
        //    else
        //    {
        //        e.EndOfItems = false;
        //    }
        //    for (int i = itemOffset; i < endOffset; i++)
        //    {
        //        RadComboBox1.Items.Add(new RadComboBoxItem(data.Rows[i]["FirstName"].ToString(), data.Rows[i]["LastName"].ToString()));
        //    }

        //    if (data.Rows.Count > 0)
        //    {
        //        e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
        //    }
        //    else
        //    {
        //        e.Message = "No matches";
        //    }
        //}
        //catch
        //{
        //    e.Message = "No matches";
        //}
    }

    protected void Button1_Click(object sender, System.EventArgs e)
    {
        //if (RadComboBox1.Text != String.Empty)
        //{
        //    Label1.Text = "You selected text: <b>" + RadComboBox1.Text + "</b> and value : <b>" + RadComboBox1.SelectedValue + "</b>";
        //}
        //else
        //{
        //    Label1.Text = "ComboBox is empty";
        //}
        BindCombo();

    }

    private void BindCombo()
    {
        ArrayList list = new ArrayList();
        
        for (int i = 0; i < 250; i++)
        {
            list.Add("string " + i);
        }
        RadComboBox1.DataSource = list;
        RadComboBox1.DataBind();
    }


}
