Help: DataRelation object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • serge calderara

    Help: DataRelation object

    Dear all,

    I have a dataset which contains 2 DataTable
    The idea is to bind a text box control with one table field and then
    diaplaye the associated content of the second table based on the first table
    entry.

    For that I have been guide to use data relation bettween those two table.
    The following code illustrate what I have done :

    ----->

    ds.Tables.AddRa nge(New DataTable() {tblCustomer, tblApplication} )

    ' Create a DataRelation, and add it to the DataSet.
    Dim dr As DataRelation
    dr = New DataRelation("c ustToApp",
    tblCustomer.Col umns.Item("ORDE R"), tblApplication. Columns.Item("O RDER_ID"))
    ds.Relations.Ad d(dr)

    Me.ListBox1.Dat aSource = ds.Tables("CUST OMER")
    Me.TextBox1.Dat aBindings.Add(N ew Binding("Text", tblCustomer, "NAME"))

    DataGrid1.Visib le = True
    DataGrid1.DataS ource = ds.Tables(1)

    ---->

    As a result I was expected that for the first entry of customer table, the
    correponding appication records for that customer gets displayed in the
    datagrid, becasue of this relation ojbect.

    But insatead in the datagrid I get all records of my application table and
    not only the one from one customer name.

    What I am doing wrong or did not understand complety. As far as I understand
    realtion between 2 coluumns from 2 different table should displayed only
    related information..

    Thnaks fro your help
    serge
  • Cor Ligthert

    #2
    Re: DataRelation object

    Serge,

    You have to bind the relation to the datagrid.

    Cor


    Comment

    • serge calderara

      #3
      Re: DataRelation object

      HOw to bind the relation to the datagrid ?

      The relation is bind to the dataset, which is linked to the datasource of
      the datagrid
      Does it not the same?

      thansk for your info

      "Cor Ligthert" wrote:
      [color=blue]
      > Serge,
      >
      > You have to bind the relation to the datagrid.
      >
      > Cor
      >
      >
      >[/color]

      Comment

      • Cor Ligthert

        #4
        Re: DataRelation object

        Serge,


        Serge

        Probably however I am always figthing with this one.

        DataGrid1.SetDa taBinding(ds, "tblCustomers.c ustToApp")

        I hope this helps,

        Cor


        Comment

        Working...