Sir,
How to use drop down list as a search text box like if country name Like U press then come like United states, United Kingdom etc.
how to use drop down in this way
Anil Jain
How use drop down list as as search text
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
SenthilkumarRank #387 · 6.5K pointsPosted Apr 7, 2012, 1:09 AM EDT
string _ConnectionString = "Data Source=SSD438\SQLEXPRESS;Initial Catalog=Master;Integrated Security=true;"; SqlConnection sqlConnection = new SqlConnection(); sqlConnection.ConnectionString = _ConnectionString; sqlConnection.Open(); string sqlQuery = "SELECT * FROM Country"; SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConnection); sqlCommand.CommandType = CommandType.Text; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); DataSet dataSet = new DataSet(); sqlDataAdapter.Fill(dataSet); ddlCountry.DataSource = dataSet.Tables[0]; ddlCountry.DataTextField = "CountryName"; ddlCountry.DataValueField = CountryID"; ddlCountry.DataBind(); protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e) { SqlConnection sqlConnection = new SqlConnection(); sqlConnection.ConnectionString = _ConnectionString; sqlConnection.Open(); string sqlQuery = "SELECT * FROM Employees WHERE name LIKE "+ddlCountry.SelectedItem.Value.ToString(); SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConnection); sqlCommand.CommandType = CommandType.Text; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); DataSet dataSet = new DataSet(); sqlDataAdapter.Fill(dataSet); GridView1.DataSource = dataSet.Tables[0]; gridView1.DataBind(); }