使用绑定源时出现问题 [英] Problem Using Binding Source

查看:69
本文介绍了使用绑定源时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在DOt Net 3.5中创建一个C#Winform,
我有一个datagridview控件&一些其他控件(2个文本框).
在我的数据集中,有两个表MasterParent(Code),MasterDetail(ParentCode).
两者都通过FkRelation关联.代码是一个自动递增列.
我创建一个绑定源(b1)&将Mastertable设置为它的数据源.现在,我将B1分配为GridView的数据源.
我创建另一个绑定源(b2)&将b1设置为数据源,将fkRelation设置为DataMember.
现在,我将2个文本框控件绑定到b2(通过使用TextBox的DataBindings).
在两个绑定源中,AllowNew,AllowEdit,AllowRemove都设置为true.
我要实现的是:
每当用户在datagridview中输入新记录时,都应在Relation中添加一个New Row.为此,我使用gridview&的UserAddedNew Row事件.调用b2.AddNew();还要在文本框中设置FK Relation ParentCode.
但是,一旦我提交了gridview行(即通过上下移动),表单视图(即texbox控件)就会丢失其Add new Event,并且b2的任何数据都不会提交到数据源.
请帮助..

Hi All,
I am creating a C# winform in DOt Net 3.5,
I have a datagridview control & a few Other Controls (2 Textbox).
In my DataSet there are two tables MasterParent(Code) ,MasterDetail(ParentCode).
Both are related by a FkRelation. Code is an AutoIncrementing Column.
I Create a binding source (b1) & set Mastertable as a DataSource to it. Now I assign B1 as a datsource to GridView.
I create another Binding Source(b2) & set b1 as datasource and fkRelation as DataMember.
Now I bind, the 2 textbox controls to b2 (by using DataBindings of TextBox).
In both the binding sources, AllowNew,AllowEdit,AllowRemove is set to true.
What I want to achieve is :
Whenever User Enters a new Record in datagridview, a New Row should get added in the Relation, For this I use UserAddedNew Row event of gridview & Call b2.AddNew();Also I set the FK Relation ParentCode in the textbox.
However, Once I Commit the gridview Row (i.e By moving up & down ), the Form View (i.e the texbox controls) Lose their Add new Event, and no data for b2 gets committed to the data source.
Kindly Help..

推荐答案

您可以发布一些代码吗?还不完全清楚这是怎么回事.另外,您是否要提交新行?
Can you post some code? Its not completely obvious what''s wrong. Also, are you committing the new row?


这篇关于使用绑定源时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆