我已经使用SQL Server作为后端开发了一个C# windows应用程序。我有一个接受用户数据的表单,数据显示在数据网格中。
然而,挑战是,我需要在输入时不断刷新此数据。我已经尝试了可能的刷新方法,但没有解决方案。
using System;
using System.Windows.Forms;
namespace Assignment_Prudence
{
public partial class StudentDeatilsPage : Form
{
public StudentDeatilsPage()
{
InitializeComponent();
}
private void StudentDeatilsPage_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'studentsDatabseDataSet.Table'
// table. You can move, or remove it, as needed.
this.tableTableAdapter.Fill(this.studentsDatabseDataSet.Table);
dataGridView1.Update();
dataGridView1.Refresh();
}
}
}发布于 2018-03-07 15:54:06
我认为你需要刷新你需要的数据,这意味着你需要调用绑定方法,请找到下面的代码供你参考
private void StudentDeatilsPage_Load(object sender, EventArgs e)
{
this.tableTableAdapter.Fill(this.studentsDatabseDataSet.Table);
LoadData();
}
private void LoadData()
{
List<Employee> StudentList = (ke.SearchStudent(txtname.Text, txtCity.Text)).ToList();
dataGridView1.DataSource = StudentList ;
dataGridView1.DataBind();
}试试看,这肯定能满足你的要求
https://stackoverflow.com/questions/49146455
复制相似问题