显示数据表格更新

本文关键字:更新 表格 数据表 数据 显示 | 更新日期: 2023-09-27 18:15:14

当我在其他表单中更新GridView数据时,然后数据更新,但当关闭此表单时,GridView数据刷新不会自动响应c# win-forms应用程序这里是我的代码:

private void button1_Click(object sender, EventArgs e)
{
    aCatagory=new tbl_Catagory();
    aContext = new RM_Inventory_DataContext();
    var product = (from p in aContext.tbl_Catagories
                   where p.CatagoriesID == Convert.ToDecimal(textBox1.Text) 
                   select p).Single();
    product.CatagoriesName = textBox2.Text;
    aContext.SubmitChanges();
    this.Close();
    AddCatagories addCatagories=new AddCatagories();
    addCatagories.GridView();
}

public void GridView()
{
    gridControl1.DataSource = new RM_PM_Inverntory_Management_System.RM_Inventory_DataContext().tbl_Catagories;
}

显示数据表格更新

在分配数据源后没有绑定gridview

public void GridView()
{
gridControl1.DataSource = What ever Data Source You have
gridControl1.DataBind();
}