|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
AD.NET 2.0: BindingSource and Parent Child relationshipI have two BindingSource(s) in my form, one for parent and one for child area. The unique situation in my form is that the child area chooses its parent by a ComboBox. The problem is when I use AndNew method in the child BindingSource, I cannot choose the parent record through the combobox and parentDataSource.Position. The parent BindingSource complains about [Not Null] columns and throws exception. This doesn't make any sense to me. I shouldn't have to use DataSet.EnforceConstraints because I do not have any NULL value at that specific parent record and position! I am sure that I am missing an important points, what is it? Any help would be appreciated, Alan Hi,
Show quote "A.M" <alanalan@newsgroup.nospam> wrote in message Could you describe the situation a little more. I mean what child and news:%23A1ps2ZJGHA.1728@TK2MSFTNGP14.phx.gbl... > Hi, > > > > I have two BindingSource(s) in my form, one for parent and one for child > area. > > > > The unique situation in my form is that the child area chooses its parent > by a ComboBox. > > > > The problem is when I use AndNew method in the child BindingSource, I > cannot choose the parent record through the combobox and > parentDataSource.Position. The parent BindingSource complains about [Not > Null] columns and throws exception. > > > > This doesn't make any sense to me. I shouldn't have to use > DataSet.EnforceConstraints because I do not have any NULL value at that > specific parent record and position! > > > > I am sure that I am missing an important points, what is it? > > > > Any help would be appreciated, parent controls are there ? And since you're trying to select a parent when you add a new child it looks more like a master-lookup scenario which is the opposite of parent-child binding and is setup differently. What are you trying to achieve ? To what are the bindingsources bound, to what and how are the controls bound, what relations are there, what's the exact error ... HTH, Greetings Show quote > > Alan > > Hi Bart,
> Could you describe the situation a little more. I mean what child and Both parent and child are WinForms textbox controls> parent controls are there ? >And since you're trying to select a parent when you add a new child it That is exactly my situation, Do you know any link to a smple?>looks more like a master-lookup scenario which is the opposite of >parent-child binding and is setup differently. > master-lookup scenario> What are you trying to achieve ? >To what are the bindingsources bound, to I have two typed datatable in my typed dataset> what and how are the controls bound, I have two .NET 2.0 Binding source in my form for parent and child> what relations are there, The dataset contains a relation between parent and child>>what's the The filed in Parent cannot be NULL> exact error ... Right now, I deleted the relationship and the form works fine. But if you could send me a sample for master-lookup scenario, it would be a great help Kind regards, Alan Show quote "Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message news:uDz0jnaJGHA.964@tk2msftngp13.phx.gbl... > Hi, > > "A.M" <alanalan@newsgroup.nospam> wrote in message > news:%23A1ps2ZJGHA.1728@TK2MSFTNGP14.phx.gbl... >> Hi, >> >> >> >> I have two BindingSource(s) in my form, one for parent and one for child >> area. >> >> >> >> The unique situation in my form is that the child area chooses its parent >> by a ComboBox. >> >> >> >> The problem is when I use AndNew method in the child BindingSource, I >> cannot choose the parent record through the combobox and >> parentDataSource.Position. The parent BindingSource complains about [Not >> Null] columns and throws exception. >> >> >> >> This doesn't make any sense to me. I shouldn't have to use >> DataSet.EnforceConstraints because I do not have any NULL value at that >> specific parent record and position! >> >> >> >> I am sure that I am missing an important points, what is it? >> >> >> >> Any help would be appreciated, > > Could you describe the situation a little more. I mean what child and > parent controls are there ? And since you're trying to select a parent > when you add a new child it looks more like a master-lookup scenario which > is the opposite of parent-child binding and is setup differently. > > What are you trying to achieve ? To what are the bindingsources bound, to > what and how are the controls bound, what relations are there, what's the > exact error ... > > > HTH, > Greetings > > >> >> Alan >> >> > > Hi,
Show quote "A.M-SG" <alanalan@newsgroup.nospam> wrote in message Not sure about your error, can't reproduce, but i can show you how a typical news:ORdYDIbJGHA.3504@TK2MSFTNGP10.phx.gbl... > Hi Bart, > >> Could you describe the situation a little more. I mean what child and >> parent controls are there ? > > Both parent and child are WinForms textbox controls > >>And since you're trying to select a parent when you add a new child it >>looks more like a master-lookup scenario which is the opposite of >>parent-child binding and is setup differently. > > That is exactly my situation, Do you know any link to a smple? > > >> >> What are you trying to achieve ? > master-lookup scenario > > >>To what are the bindingsources bound, to > I have two typed datatable in my typed dataset > > >> what and how are the controls bound, > I have two .NET 2.0 Binding source in my form for parent and child > >> what relations are there, > The dataset contains a relation between parent and child > >>>what's the >> exact error ... > > The filed in Parent cannot be NULL master-lookup binding looks like: DataSet ds = new DataSet(); // has two tables (with or without relation, shouldn't matter) BindingSource productSource = new BindingSource(ds, "Product"); BindingSource categorySource = new BindingSource(ds, "Category"); // bind lookup ComboBox1.DataSource = categorySource; ComboBox1.DisplayMember = "CategoryName"; ComboBox1.ValueMember = "CategoryId"; // pk // bind master fields ComboBox1.DataBindings.Add("SelectedValue", productSource, "CategoryId"); // fk TextBox1.DataBindings.Add("Text", productSource, "ProductDesription" ); HTH, Greetings Show quote > > > Right now, I deleted the relationship and the form works fine. But if you > could send me a sample for master-lookup scenario, it would be a great > help > > > Kind regards, > Alan > > > > > "Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message > news:uDz0jnaJGHA.964@tk2msftngp13.phx.gbl... >> Hi, >> >> "A.M" <alanalan@newsgroup.nospam> wrote in message >> news:%23A1ps2ZJGHA.1728@TK2MSFTNGP14.phx.gbl... >>> Hi, >>> >>> >>> >>> I have two BindingSource(s) in my form, one for parent and one for child >>> area. >>> >>> >>> >>> The unique situation in my form is that the child area chooses its >>> parent by a ComboBox. >>> >>> >>> >>> The problem is when I use AndNew method in the child BindingSource, I >>> cannot choose the parent record through the combobox and >>> parentDataSource.Position. The parent BindingSource complains about [Not >>> Null] columns and throws exception. >>> >>> >>> >>> This doesn't make any sense to me. I shouldn't have to use >>> DataSet.EnforceConstraints because I do not have any NULL value at that >>> specific parent record and position! >>> >>> >>> >>> I am sure that I am missing an important points, what is it? >>> >>> >>> >>> Any help would be appreciated, >> >> Could you describe the situation a little more. I mean what child and >> parent controls are there ? And since you're trying to select a parent >> when you add a new child it looks more like a master-lookup scenario >> which is the opposite of parent-child binding and is setup differently. >> >> What are you trying to achieve ? To what are the bindingsources bound, to >> what and how are the controls bound, what relations are there, what's the >> exact error ... >> >> >> HTH, >> Greetings >> >> >>> >>> Alan >>> >>> >> >> > > Yes, Alan. Could you give us a simple repro step, so that we can deliver
our assistance more quickly? Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Hi Kevin,
Thank you for follow up. Since the code is part of a big/complex component, it would take a while to write some code to reproduce it. At this point I removed the relations between data and it works okay without relationships. I'll work to reproduce the problem with smaller scale code and then create another post to share it with everybody. Thanks again, Alan Show quote "Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message news:PcVa9pgJGHA.1236@TK2MSFTNGXA02.phx.gbl... > Yes, Alan. Could you give us a simple repro step, so that we can deliver > our assistance more quickly? > > Kevin Yu > ======= > "This posting is provided "AS IS" with no warranties, and confers no > rights." > Thank you Alan.
Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Thank yoy Bart for sharing the code.
My code does the similar thing, but it also shows the parent data in separated set of text boxes by changing the popsition of the second binding source control. I am going to work on reproducing the problem in smaller scale code and share it on another post Kind regards, Alan Show quote "Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message news:OfvxGebJGHA.2628@TK2MSFTNGP15.phx.gbl... > Hi, > > "A.M-SG" <alanalan@newsgroup.nospam> wrote in message > news:ORdYDIbJGHA.3504@TK2MSFTNGP10.phx.gbl... >> Hi Bart, >> >>> Could you describe the situation a little more. I mean what child and >>> parent controls are there ? >> >> Both parent and child are WinForms textbox controls >> >>>And since you're trying to select a parent when you add a new child it >>>looks more like a master-lookup scenario which is the opposite of >>>parent-child binding and is setup differently. >> >> That is exactly my situation, Do you know any link to a smple? >> >> >>> >>> What are you trying to achieve ? >> master-lookup scenario >> >> >>>To what are the bindingsources bound, to >> I have two typed datatable in my typed dataset >> >> >>> what and how are the controls bound, >> I have two .NET 2.0 Binding source in my form for parent and child >> >>> what relations are there, >> The dataset contains a relation between parent and child >> >>>>what's the >>> exact error ... >> >> The filed in Parent cannot be NULL > > Not sure about your error, can't reproduce, but i can show you how a > typical master-lookup binding looks like: > > DataSet ds = new DataSet(); // has two tables (with or without relation, > shouldn't matter) > BindingSource productSource = new BindingSource(ds, "Product"); > BindingSource categorySource = new BindingSource(ds, "Category"); > > // bind lookup > ComboBox1.DataSource = categorySource; > ComboBox1.DisplayMember = "CategoryName"; > ComboBox1.ValueMember = "CategoryId"; // pk > > // bind master fields > ComboBox1.DataBindings.Add("SelectedValue", productSource, "CategoryId"); > // fk > TextBox1.DataBindings.Add("Text", productSource, "ProductDesription" ); > > > HTH, > Greetings > > >> >> >> Right now, I deleted the relationship and the form works fine. But if you >> could send me a sample for master-lookup scenario, it would be a great >> help >> >> >> Kind regards, >> Alan >> >> >> >> >> "Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message >> news:uDz0jnaJGHA.964@tk2msftngp13.phx.gbl... >>> Hi, >>> >>> "A.M" <alanalan@newsgroup.nospam> wrote in message >>> news:%23A1ps2ZJGHA.1728@TK2MSFTNGP14.phx.gbl... >>>> Hi, >>>> >>>> >>>> >>>> I have two BindingSource(s) in my form, one for parent and one for >>>> child area. >>>> >>>> >>>> >>>> The unique situation in my form is that the child area chooses its >>>> parent by a ComboBox. >>>> >>>> >>>> >>>> The problem is when I use AndNew method in the child BindingSource, I >>>> cannot choose the parent record through the combobox and >>>> parentDataSource.Position. The parent BindingSource complains about >>>> [Not Null] columns and throws exception. >>>> >>>> >>>> >>>> This doesn't make any sense to me. I shouldn't have to use >>>> DataSet.EnforceConstraints because I do not have any NULL value at that >>>> specific parent record and position! >>>> >>>> >>>> >>>> I am sure that I am missing an important points, what is it? >>>> >>>> >>>> >>>> Any help would be appreciated, >>> >>> Could you describe the situation a little more. I mean what child and >>> parent controls are there ? And since you're trying to select a parent >>> when you add a new child it looks more like a master-lookup scenario >>> which is the opposite of parent-child binding and is setup differently. >>> >>> What are you trying to achieve ? To what are the bindingsources bound, >>> to what and how are the controls bound, what relations are there, what's >>> the exact error ... >>> >>> >>> HTH, >>> Greetings >>> >>> >>>> >>>> Alan >>>> >>>> >>> >>> >> >> > > |
|||||||||||||||||||||||