[英]Display specific rows and update in GridView using Linq database c#
I am new in C# and I want to display specific rows in GridView. 我是C#的新手,我想在GridView中显示特定的行。 I could do this but I could not update it.
我可以这样做,但无法更新。 My code:
我的代码:
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;
}
I called bindgridview() in bossAcc_Load function.In my form,I have add_new button and save button. 我在bossAcc_Load函数中调用bindgridview()。在我的表单中,我具有add_new按钮和Save按钮。 This is save button function:
这是保存按钮功能:
private void button5_Click(object sender, EventArgs e)
{
this.Validate();
this.employeeBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.my_proDataSet);
}
But when I click save button,didn't update data.What should I do? 但是,当我单击“保存”按钮时,没有更新数据。该怎么办?
Try this, 尝试这个,
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.