LINQ 数据源和 BindingNavigator 更新不起作用
我正在尝试将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在保存操作发生之前对绑定源调用 EndEdit。
Try to call EndEdit on binding source just before save operation to happen.