LINQ 数据源和 BindingNavigator 更新不起作用

发布于 2024-10-15 12:17:51 字数 613 浏览 6 评论 0原文

我正在尝试将 LINQ 查询设置为 BindingNavigator 控件的数据源。

在表单的变量中,我添加了一个数据上下文:

`Private c

tx As New myDataManagerDataContext`

以下代码允许我显示和浏览结果:

Dim clubList = From c In ctx.clubs _
                   Select c

BindingNavigator1.BindingSource.DataSource = clubList

到目前为止,每条记录都显示得很好。 在Winform中,所有文本框都适当地绑定到数据源,但我的问题是:

我添加了一个Save ToolboxButton: ctx.SubmitChanges()

但它不处理任何更新!

问题:我是否必须在“保存”按钮中编写完整的插入/更新 Linq 过程?

像:

Dim newClub as new DataContext.Club newClub.Name = NameTextBox.Text newClub.Address...等等

I'm trying to set a LINQ query as the DataSource of a BindingNavigator control.

In the form's variables I added a data context:

`Private c

tx As New myDataManagerDataContext`

The following code allows me to display and navigate through the results:

Dim clubList = From c In ctx.clubs _
                   Select c

BindingNavigator1.BindingSource.DataSource = clubList

Each record is displayed nicely so far.
In the Winform, all textboxes are duly binded to the datasource but my problem is:

I added a Save ToolboxButton with: ctx.SubmitChanges()

But it doesn't process any update!

Question: Do I HAVE to write a complete Insert/ Update Linq procedure in the Save button?

Like:

Dim newClub as new DataContext.Club
newClub.Name = NameTextBox.Text
newClub.Address.... Etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我三岁 2024-10-22 12:17:51

尝试在保存操作发生之前对绑定源调用 EndEdit。

Try to call EndEdit on binding source just before save operation to happen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文