TextChanged 事件搜索在我的代码中无法正常工作

问题描述 投票:0回答:1
    private void dataGridView_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        StateTextboxes(true);
        btnUpdate.Enabled = true;
        btnDelete.Enabled = true;
        btnNew.Enabled = false;
        btnClear.Enabled = true;
        StateTextboxes(true);
        DataGridToTextBoxes();
    }
    private void DataGridToTextBoxes()
    {
        txtID.Text = dataGridView.CurrentRow.Cells["id"].Value.ToString();
        id = Int32.Parse(txtID.Text);
        txtCompany.Text = dataGridView.CurrentRow.Cells["Company"].Value.ToString();
        txtFirstname.Text = dataGridView.CurrentRow.Cells["FirstName"].Value.ToString();
        txtLastname.Text = dataGridView.CurrentRow.Cells["LastName"].Value.ToString();
    }
    private void TextChanged_Search_Load(object sender, EventArgs e)
    {
        searchData("");
    } 
    private void txtSearch_TextChanged(object sender, EventArgs e)
    {
        searchData(txtSearch.Text);
    }
    private void searchData(string text)
    { 
        using (MySqlConnection mySqlConnection = new MySqlConnection(stdConnection))
        {
            mySqlConnection.Open();
            MySqlDataAdapter msda = new MySqlDataAdapter("BC_Search", mySqlConnection);
            msda.SelectCommand.CommandType = CommandType.StoredProcedure;
            msda.SelectCommand.Parameters.AddWithValue("_SearchValue", txtSearch.Text);

            DataTable dt = new DataTable();
            msda.Fill(dt);
            dataGridView.DataSource = dt;
            throw new NotImplementedException();
        }
    } 
  • //软件无法执行此代码得到错误,该异常最初是在此调用堆栈处抛出的:
  • //[外部代码]
  • //frmMain.cs 中的 BusinessCardDB.frmMain.searchData(string)
  • //frmMain.cs 中的 BusinessCardDB.frmMain.txtSearch_TextChanged(object, System.EventArgs)
  • //[外部代码]
  • //Program.cs 中的 BusinessCardDB.Program.Main()
c#
1个回答
0
投票

另请查看这篇文章:文本更改事件未触发

需要仔细检查的关键注释,因为这些注释始终是必需的: “您需要将 AutoPostBack 设置为 true。”。 和: “”。

© www.soinside.com 2019 - 2024. All rights reserved.