Re: Related column values

From: Nicolas L. (jnlinale_at_yahoo.com)
Date: 12/20/04


Date: Mon, 20 Dec 2004 03:40:23 -0300

Users table is in a relation 1-to-many with Orders, so if you want to add
First and Last Name of Users to Orders,
you could add one more DataColumn to table Orders and set the expression to:

     Dim dcFullName As DataColumn

     ' Create the column.
     dcFullName = New DataColumn
     With dcFullName
         .DataType = System.Type.GetType("System.String")
         .ColumnName = "FullName"
         .Expression = "Parent.FirstName + Parent.LastName"
     End With

    myDataSet.Table("Orders").Columns.Add(dcFullName)

Don't forget to include the "Parent." in the expression because you're
referring a parent table from its child, to refer a child from its parent
you must antepone "Child." to the column name. For a complete use of
DataColumn.Expression Property go to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp

Nicolas L.

"Oleg Ogurok" <oleg@ogurok.com.ihatespammers.ireallydo.co> escribió en el
mensaje news:10s9v62sn0r55b4@corp.supernews.com...
> Hi all,
>
> I have a strongly typed dataset with tables:
> Users: ID, First Name, LastName
> Orders: ID, Quantity, UserID
>
> UserID is related to Users' ID column via a DataRelation.
>
> I'm binding Orders table to a DataGrid, and one of the columns I need to
> be
> the First+Last name of the corresponding user.
> How can I accomplish it?
>
> Also, if I need to filter the orders by UserID, can I use DataView in my
> scenario?
>
> I tried adding a DataGridColumnStyle and setting MappingProperty to bunch
> of
> different values but none worked.
>
> Also, any examples, tutorials on DataGrid are gladly appreciated.
> Thanks.
> -Oleg.
>
>
>
>



Relevant Pages

  • Re: Binding to a related column
    ... Don't forget to include the "Parent." ... referring a parent table from its child, to refer a child from its parent ... > UserID is related to Users' ID column via a DataRelation. ... any tutorials on DataGrid are gladly appreciated. ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: newbie - simple Master/Details question
    ... I changed the way I handle my SQL, and made the child table's SQL statement ... fields being searched upon in the parent, don't occur in the child - it got ... In MSHFlexGrid, the only navigation was the "+" button, and the scroll ... I am trying to find a way of doing this in a single datagrid though, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Parent -Child relationship
    ... Binding with relations has forever been a problem in 1.1. ... Child Table ... Then I bind the parent table to a DataGrid and the DefaultView of the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Parent -Child relationship
    ... DataRelation, for example let's analyze this couple: ... Child Table ... Then I bind the parent table to a DataGrid and the DefaultView of the ...
    (microsoft.public.dotnet.framework.adonet)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)