⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultcs.aspx.cs

📁 Telerik是很大的第三方软件制造商
💻 CS
字号:
using System;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using Telerik.QuickStart;
using Telerik.WebControls;

namespace Telerik.ComboboxExamplesCS.AutoCompleteClientSide
{
	/// <summary>
	/// Summary description for _Default.
	/// </summary>
	public class DefaultCS: XhtmlPage
	{
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.CheckBox CheckBox1;
		protected System.Web.UI.WebControls.Label Label1;	
		protected RadComboBox RadComboBox1;		
		
		private void PopulateCombo()
		{
			string mdbPath = Server.MapPath("~/Combobox/Data/NWind.mdb"); 
			OleDbConnection dbCon = new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath); 
			dbCon.Open();
		
			string sql = "SELECT * FROM Customers ORDER BY ContactName";
			OleDbDataAdapter adapter = new OleDbDataAdapter(sql, dbCon);
			DataTable dt = new DataTable();
			adapter.Fill(dt);
			dbCon.Close();
			
			foreach (DataRow row in dt.Rows)
			{
				string [] names = row["ContactName"].ToString().ToLower().Split(' ');
				string email = names[0] + "@telerik.com";
				RadComboBoxItem item = new RadComboBoxItem(email);
				RadComboBox1.Items.Add(item);
			}
		}

		private void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				PopulateCombo();
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{			
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.CheckBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			Label1.Text = "You have selected the following email: " + RadComboBox1.Text;			
		}

		private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			RadComboBox1.AllowCustomText = CheckBox1.Checked;
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -