簡體   English   中英

使用Linq數據庫C#顯示特定行並在GridView中更新

[英]Display specific rows and update in GridView using Linq database c#

我是C#的新手,我想在GridView中顯示特定的行。 我可以這樣做,但無法更新。 我的代碼:

 private void bindGridView()
    {
        myContextDataContext context = new myContextDataContext();
        var q2 = from p in context.employees
                 where p.check_is_mngr == 1
                 select p;
        employeeDataGridView.DataSource = q2;
    }

我在bossAcc_Load函數中調用bindgridview()。在我的表單中,我具有add_new按鈕和Save按鈕。 這是保存按鈕功能:

private void button5_Click(object sender, EventArgs e)
    {
        this.Validate();
        this.employeeBindingSource.EndEdit();
        this.tableAdapterManager.UpdateAll(this.my_proDataSet);   

    }

但是,當我單擊“保存”按鈕時,沒有更新數據。該怎么辦?

嘗試這個,

var q2 = from p in context.employees
                 where p.check_is_mngr == 1
                 select p;
employeeDataGridView.DataSource = null;
employeeDataGridView.DataSource = q2 ;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM