Databindings and Relationships

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Oliver Lundt via .NET 247 (anonymous_at_dotnet247.com)
Date: 10/31/04


Date: Sun, 31 Oct 2004 03:56:17 -0800

I have a combobox bound to a table with a relationship. When the combobox selection changes the I change the values displayed. It works fine but only on the field in the same table. It relationship doesn't allow me to display values from the other table. Here my code:

//Add Relationships
DataRelation horseLocation = new DataRelation("HorseLocation",dsMain.Tables["tblLocation"].Columns["LocationId"],dsMain.Tables["tblHorseInfo"].Columns["LocationId"]);
dsMain.Relations.Add(horseLocation);

//fill combo box and values
lstHorses.DataSource = dsMain.Tables["tblHorseInfo"];
lstHorses.ValueMember = "HorseId";
lstHorses.DisplayMember = "HorseName";

lblOwner.DataBindings.Add("Text",dsMain.Tables["tblHorseInfo"].DefaultView,"OwnerName");
lblLocation.DataBindings.Add("Text",dsMain.Tables["tblHorseInfo"],"HorseLocation.tblHorseInfo.LocationName");

lblLocation is the databinding that is not working!!
I have the RelationshipName.TableName.TableField
Any ideas???
Thanks

--------------------------------
From: Oliver Lundt

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>2q4N+fmkpk2E7QtW2xWOSw==</Id>



Relevant Pages

  • Databindings and Relationships
    ... lstHorses.ValueMember = "HorseId"; ... lstHorses.DisplayMember = "HorseName"; ... lblLocation is the databinding that is not working!! ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Databindings and Relationships
    ... lstHorses.ValueMember = "HorseId"; ... lstHorses.DisplayMember = "HorseName"; ... lblLocation is the databinding that is not working!! ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Databindings and Relationships
    ... lstHorses.ValueMember = "HorseId"; ... lstHorses.DisplayMember = "HorseName"; ... lblLocation is the databinding that is not working!! ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: Databindings and Relationships
    ... >lblLocation is the databinding that is not working!! ... CurrencyManagers - Try changing the second to ... It relationship doesn't allow me to display ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)