2014-02-10 22 views
0

我試圖將文本框綁定到C#中的下拉列表中。我無法綁定文本框和下拉列表。如何通過在文本框中輸入值來過濾下拉列表中的值

幫助我這個代碼

public void BindDropDownListData() 
{ 
    String strConnString = ConfigurationManager.ConnectionStrings["sample11"].ConnectionString; 
    using (SqlConnection mySqlConnection = new SqlConnection(strConnString)) 
    { 
     try 
     { 
      mySqlConnection.Open(); 
      SqlCommand mySqlCommand = new SqlCommand("dbo.SCM_JOB_DISPLAY", mySqlConnection); 
      mySqlCommand.CommandType = CommandType.StoredProcedure; 
      SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySqlCommand); 
      DataSet myDataSet = new DataSet(); 
      mySqlDataAdapter.Fill(myDataSet); 
      DropDownList1.DataSource = myDataSet; 
      DropDownList1.DataTextField = "HTTIS_Issue_Number"; 
      DropDownList1.DataValueField = "HTTIS_Job_Code"; 
      DropDownList1.DataBind(); 
     } 
     catch (Exception ex) 
     { 
      Label1.Text = ex.Message; 
     } 
     finally 
     { 
      mySqlConnection.Close(); 
     } 
    } 
} 
+0

你在哪裏綁定文本框與此代碼中的下拉列表。 –

+0

@Irfan我們嘗試了很多綁定的代碼,但是我們收到了錯誤消息。所以目前即時通訊等待幫助綁定文本框 – Jan

+0

那麼它是什麼意思..「將文本框綁定到下拉列表」。顯示你的嘗試,這將告訴你正在嘗試做什麼。 –

回答

0

嘗試結合

myDataSet.Tables[0] 

而不是整個數據集。

相關問題