C# winform 在dataGridView中的查询怎样显示?
数据源已经绑定好了,我通过输入的字段重新绑定数据源来达到查询目的怎么实现不了?要怎么才能实现?namespaceJiXiao{publicpartialclassEndS...
数据源已经绑定好了,我通过输入的字段重新绑定数据源来达到查询目的怎么实现不了?要怎么才能实现?
namespace JiXiao{ public partial class EndScore : Form { public EndScore() { InitializeComponent(); //手动绑定dataGridView2代码,将表格显示到dataGridView中 SqlConnection conn0 = Connect(); SqlDataAdapter sda0 = new SqlDataAdapter("Select UserId,UserName,UserAvg From [tb_user]", conn0); DataSet Ds0 = new DataSet(); sda0.Fill(Ds0, "tb_user"); this.dataGridView1.DataSource = Ds0; this.dataGridView1.DataMember = "tb_user"; conn0.Close(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) {
}
private void textBox1_TextChanged(object sender, EventArgs e) { string a1 = textBox1.Text.Trim(); SqlConnection conn77 = Connect(); SqlDataAdapter sda77 = new SqlDataAdapter("Select UserId,UserName,UserAvg From [tb_user] where UserId like '"+a1.Trim()+"'", conn77); DataSet Ds77 = new DataSet(); sda77.Fill(Ds77, "tb_user"); this.dataGridView1.DataSource = Ds77; this.dataGridView1.DataMember = "tb_user"; conn77.Close(); } }} 展开
namespace JiXiao{ public partial class EndScore : Form { public EndScore() { InitializeComponent(); //手动绑定dataGridView2代码,将表格显示到dataGridView中 SqlConnection conn0 = Connect(); SqlDataAdapter sda0 = new SqlDataAdapter("Select UserId,UserName,UserAvg From [tb_user]", conn0); DataSet Ds0 = new DataSet(); sda0.Fill(Ds0, "tb_user"); this.dataGridView1.DataSource = Ds0; this.dataGridView1.DataMember = "tb_user"; conn0.Close(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) {
}
private void textBox1_TextChanged(object sender, EventArgs e) { string a1 = textBox1.Text.Trim(); SqlConnection conn77 = Connect(); SqlDataAdapter sda77 = new SqlDataAdapter("Select UserId,UserName,UserAvg From [tb_user] where UserId like '"+a1.Trim()+"'", conn77); DataSet Ds77 = new DataSet(); sda77.Fill(Ds77, "tb_user"); this.dataGridView1.DataSource = Ds77; this.dataGridView1.DataMember = "tb_user"; conn77.Close(); } }} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询